﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using XChipTool.Enties;
using XChip_Common;
using System.IO;
using System.Configuration;
using System.IO.Ports;
using SerialPortHelperLib;

namespace XChipTool
{
    public partial class XChip_SecurityFile64 : DevExpress.XtraEditors.XtraForm
    {

        #region 全局变量

        int type = 0;
        //bindriving BinDri;
        bincurrency BinCur;
        bindefault BinDef;
        //private int Id = -1;
        private string GuidNo;
       
        List<List<TreeListValue>> SettingList = new List<List<TreeListValue>>();
        public bincurrencyManager Bincurrency_BLL = new bincurrencyManager();
        public delegate void SendEventBinSettingNewClick(string list,bool isP_key);

        public event SendEventBinSettingNewClick SendBinSetClick;
        bool isloadAgain = false;//是否再次加载标志 

        public delegate void SendEventBinSettingNewMsg(string msg);
        public event SendEventBinSettingNewMsg SendBinSetMsg;


        public bool isPollingSetOk = false;//轮询setting是否ok的标志
        public bool isOsd = false;
        public int isPress_key;// -1 表示无选着  0 表示案件 1表示adc
        public bool isOsdVerCheck = false;//勾选版本号
        private List<BinChoiceData> listBin = new List<BinChoiceData>();

        bool beginMove = false;
        int currentXPosition;
        int currentYPosition;

        public SerialPort sPortTemp;
        List<TreeListValue> commonList = new List<TreeListValue>();
        #endregion

        public XChip_SecurityFile64()
        {
            InitializeComponent();
        }
        public XChip_SecurityFile64(int _type, bincurrency binmodel, bindefault binD, string guid,bool _isOsd, SerialPort _sPortTemp, int _isPress_key = -1,bool _isOsdVerCheck= false)
        {
            InitializeComponent();
            type = _type;
            BinCur = binmodel;
            BinDef = binD;
            GuidNo = guid;
            isOsd = _isOsd;
            isPress_key = _isPress_key;
            sPortTemp = _sPortTemp;
            btn_polling.Visible = !(isPress_key == -1);
            isOsdVerCheck = _isOsdVerCheck;
            SetNumFirst(false, 0);
        }

        private void XChip_SecurityFile_Load(object sender, EventArgs e)
        {

            navigationPane1.SelectedPage = thdPage;
            navigationPane1.SelectedPage = chdPage;
            navigationPane1.SelectedPage = cvbsPage;
            navigationPane1.SelectedPage = ahdPage;
            #region 区分又没有osd
            if (!isOsd) // 没有osd 情况 修改文字
            {
                SetLookEditTag(0, 8, 16, 24);//先设置tag
                ahdPage.Caption = "1-8配置";
                thdPage.Caption = "9-16配置";
                chdPage.Caption = "17-24配置";
                cvbsPage.Caption = "25-32配置";

                txtlabtvi_1.Text = "文件路径9：";
                txtlabtvi_2.Text = "文件路径10：";
                txtlabtvi_3.Text = "文件路径11：";
                txtlabtvi_4.Text = "文件路径12：";
                txtlabtvi_5.Text = "文件路径13：";
                txtlabtvi_6.Text = "文件路径14：";
                txtlabtvi_7.Text = "文件路径15：";
                txtlabtvi_8.Text = "文件路径16：";


                txtlabcvi_1.Text = "文件路径17：";
                txtlabcvi_2.Text = "文件路径18：";
                txtlabcvi_3.Text = "文件路径19：";
                txtlabcvi_4.Text = "文件路径20：";
                txtlabcvi_5.Text = "文件路径21：";
                txtlabcvi_6.Text = "文件路径22：";
                txtlabcvi_7.Text = "文件路径23：";
                txtlabcvi_8.Text = "文件路径24：";

                txtlabcvbs_1.Text = "文件路径25：";
                txtlabcvbs_2.Text = "文件路径26：";
                txtlabcvbs_3.Text = "文件路径27：";
                txtlabcvbs_4.Text = "文件路径28：";
                txtlabcvbs_5.Text = "文件路径29：";
                txtlabcvbs_6.Text = "文件路径30：";
                txtlabcvbs_7.Text = "文件路径31：";
                txtlabcvbs_8.Text = "文件路径32：";
               
            }
            else {
                //根据osd 排序 确定0，1，2，3  现在默认放  ahd =0， THD=1， CHD=2, cvbs =3; 

                var i0 = Convert.ToInt16(SettingList_Help.SetTips128[0].Tag);
                var i1 = Convert.ToInt16(SettingList_Help.SetTips128[8].Tag);
                var i2 = Convert.ToInt16(SettingList_Help.SetTips128[16].Tag);
                var i3 = Convert.ToInt16(SettingList_Help.SetTips128[24].Tag);
                SetLookEditTag(i0, i1, i2, i3);//先设置tag

                if (!string.IsNullOrEmpty(SettingList_Help.SetTips128[0].Mode))
                {
                    ahdPage.Caption = $"{SettingList_Help.SetTips128[0].Mode}配置";
                    txtlabahd_1.Text = string.IsNullOrEmpty(SettingList_Help.SetTips128[0].Tips)? "建议不放": SettingList_Help.SetTips128[0].Tips;
                    ahdpage1.Visible = !txtlabahd_1.Text.Contains("建议");
                    listBin.Add(new BinChoiceData() { tag = int.Parse(settingPathahd_1.Tag.ToString()), BinName = SettingList_Help.SetTips128[0].Tips,isShow = !txtlabahd_1.Text.Contains("建议") });
                    txtlabahd_2.Text = string.IsNullOrEmpty(SettingList_Help.SetTips128[1].Tips)? "建议不放": SettingList_Help.SetTips128[1].Tips;
                    ahdpage2.Visible = !txtlabahd_2.Text.Contains("建议");
                    listBin.Add(new BinChoiceData() { tag = int.Parse(settingPathahd_2.Tag.ToString()), BinName = SettingList_Help.SetTips128[1].Tips, isShow = !txtlabahd_2.Text.Contains("建议")  });
                    txtlabahd_3.Text = string.IsNullOrEmpty(SettingList_Help.SetTips128[2].Tips)? "建议不放": SettingList_Help.SetTips128[2].Tips;
                    ahdpage3.Visible = !txtlabahd_3.Text.Contains("建议");
                    listBin.Add(new BinChoiceData() { tag = int.Parse(settingPathahd_3.Tag.ToString()), BinName = SettingList_Help.SetTips128[2].Tips, isShow = !txtlabahd_3.Text.Contains("建议")  });
                    txtlabahd_4.Text = string.IsNullOrEmpty(SettingList_Help.SetTips128[3].Tips)? "建议不放": SettingList_Help.SetTips128[3].Tips;
                    ahdpage4.Visible = !txtlabahd_4.Text.Contains("建议");
                    listBin.Add(new BinChoiceData() { tag = int.Parse(settingPathahd_4.Tag.ToString()), BinName = SettingList_Help.SetTips128[3].Tips, isShow = !txtlabahd_4.Text.Contains("建议") });
                    txtlabahd_5.Text = string.IsNullOrEmpty(SettingList_Help.SetTips128[4].Tips)? "建议不放": SettingList_Help.SetTips128[4].Tips;
                    ahdpage5.Visible = !txtlabahd_5.Text.Contains("建议");
                    listBin.Add(new BinChoiceData() { tag = int.Parse(settingPathahd_5.Tag.ToString()), BinName = SettingList_Help.SetTips128[4].Tips, isShow = !txtlabahd_5.Text.Contains("建议") });
                    txtlabahd_6.Text = string.IsNullOrEmpty(SettingList_Help.SetTips128[5].Tips)? "建议不放": SettingList_Help.SetTips128[5].Tips;
                    ahdpage6.Visible = !txtlabahd_6.Text.Contains("建议");
                    listBin.Add(new BinChoiceData() { tag = int.Parse(settingPathahd_6.Tag.ToString()), BinName = SettingList_Help.SetTips128[5].Tips, isShow = !txtlabahd_6.Text.Contains("建议")  });
                    txtlabahd_7.Text = string.IsNullOrEmpty(SettingList_Help.SetTips128[6].Tips)? "建议不放": SettingList_Help.SetTips128[6].Tips;
                    ahdpage7.Visible = !txtlabahd_7.Text.Contains("建议");
                    listBin.Add(new BinChoiceData() { tag = int.Parse(settingPathahd_7.Tag.ToString()), BinName = SettingList_Help.SetTips128[6].Tips, isShow = !txtlabahd_7.Text.Contains("建议")  });
                    txtlabahd_8.Text = string.IsNullOrEmpty(SettingList_Help.SetTips128[7].Tips) ? "建议不放" : SettingList_Help.SetTips128[7].Tips;
                    ahdpage8.Visible = !txtlabahd_8.Text.Contains("建议");
                    listBin.Add(new BinChoiceData() { tag = int.Parse(settingPathahd_8.Tag.ToString()), BinName = SettingList_Help.SetTips128[7].Tips, isShow = !txtlabahd_8.Text.Contains("建议")  });

                    if (SettingList_Help.SetTips128.Count(c => c.Mode == SettingList_Help.SetTips128[0].Mode && !string.IsNullOrEmpty(c.Tips)) <= 0)
                    {
                        ahdPage.PageVisible = false;
                        navigationPane1.SelectedPage = thdPage;
                    }
                }
                else {
                    ahdPage.PageVisible = false;
                }
                if (!string.IsNullOrEmpty(SettingList_Help.SetTips128[8].Mode))
                {
                    thdPage.Caption = $"{SettingList_Help.SetTips128[8].Mode}配置";
                    txtlabtvi_1.Text = string.IsNullOrEmpty(SettingList_Help.SetTips128[8].Tips) ? "建议不放" : SettingList_Help.SetTips128[8].Tips;
                    tvipage1.Visible = !txtlabtvi_1.Text.Contains("建议");
                    listBin.Add(new BinChoiceData() { tag = int.Parse(settingPathtvi_1.Tag.ToString()), BinName = SettingList_Help.SetTips128[8].Tips, isShow = !txtlabtvi_1.Text.Contains("建议") });
                    txtlabtvi_2.Text = string.IsNullOrEmpty(SettingList_Help.SetTips128[9].Tips) ? "建议不放" : SettingList_Help.SetTips128[9].Tips;
                    tvipage2.Visible = !txtlabtvi_2.Text.Contains("建议");
                    listBin.Add(new BinChoiceData() { tag = int.Parse(settingPathtvi_2.Tag.ToString()), BinName = SettingList_Help.SetTips128[9].Tips, isShow = !txtlabtvi_2.Text.Contains("建议") });
                    txtlabtvi_3.Text = string.IsNullOrEmpty(SettingList_Help.SetTips128[10].Tips) ? "建议不放" : SettingList_Help.SetTips128[10].Tips;
                    tvipage3.Visible = !txtlabtvi_3.Text.Contains("建议");
                    listBin.Add(new BinChoiceData() { tag = int.Parse(settingPathtvi_3.Tag.ToString()), BinName = SettingList_Help.SetTips128[10].Tips, isShow = !txtlabtvi_3.Text.Contains("建议") });
                    txtlabtvi_4.Text = string.IsNullOrEmpty(SettingList_Help.SetTips128[11].Tips) ? "建议不放" : SettingList_Help.SetTips128[11].Tips;
                    tvipage4.Visible = !txtlabtvi_4.Text.Contains("建议");
                    listBin.Add(new BinChoiceData() { tag = int.Parse(settingPathtvi_4.Tag.ToString()), BinName = SettingList_Help.SetTips128[11].Tips, isShow = !txtlabtvi_4.Text.Contains("建议") });
                    txtlabtvi_5.Text = string.IsNullOrEmpty(SettingList_Help.SetTips128[12].Tips) ? "建议不放" : SettingList_Help.SetTips128[12].Tips;
                    tvipage5.Visible = !txtlabtvi_5.Text.Contains("建议");
                    listBin.Add(new BinChoiceData() { tag = int.Parse(settingPathtvi_5.Tag.ToString()), BinName = SettingList_Help.SetTips128[12].Tips, isShow = !txtlabtvi_5.Text.Contains("建议")  });
                    txtlabtvi_6.Text = string.IsNullOrEmpty(SettingList_Help.SetTips128[13].Tips) ? "建议不放" : SettingList_Help.SetTips128[13].Tips;
                    tvipage6.Visible = !txtlabtvi_6.Text.Contains("建议");
                    listBin.Add(new BinChoiceData() { tag = int.Parse(settingPathtvi_6.Tag.ToString()), BinName = SettingList_Help.SetTips128[13].Tips, isShow = !txtlabtvi_6.Text.Contains("建议")  });
                    txtlabtvi_7.Text = string.IsNullOrEmpty(SettingList_Help.SetTips128[14].Tips) ? "建议不放" : SettingList_Help.SetTips128[14].Tips;
                    tvipage7.Visible = !txtlabtvi_7.Text.Contains("建议");
                    listBin.Add(new BinChoiceData() { tag = int.Parse(settingPathtvi_7.Tag.ToString()), BinName = SettingList_Help.SetTips128[14].Tips, isShow = !txtlabtvi_7.Text.Contains("建议")  });
                    txtlabtvi_8.Text = string.IsNullOrEmpty(SettingList_Help.SetTips128[15].Tips) ? "建议不放" : SettingList_Help.SetTips128[15].Tips;
                    tvipage8.Visible = !txtlabtvi_8.Text.Contains("建议");
                    listBin.Add(new BinChoiceData() { tag = int.Parse(settingPathtvi_8.Tag.ToString()), BinName = SettingList_Help.SetTips128[15].Tips, isShow = !txtlabtvi_8.Text.Contains("建议") });

                    if (SettingList_Help.SetTips128.Count(c => c.Mode == SettingList_Help.SetTips128[8].Mode && !string.IsNullOrEmpty(c.Tips)) <= 0)
                    {
                        thdPage.PageVisible = false;
                        navigationPane1.SelectedPage = chdPage;
                    }
                }
                else {
                    thdPage.PageVisible = false;
                }

                if (!string.IsNullOrEmpty(SettingList_Help.SetTips128[16].Mode))
                {
                    chdPage.Caption = $"{SettingList_Help.SetTips128[16].Mode}配置";
                    txtlabcvi_1.Text = string.IsNullOrEmpty(SettingList_Help.SetTips128[16].Tips) ? "建议不放" : SettingList_Help.SetTips128[16].Tips;
                    cvipage1.Visible = !txtlabcvi_1.Text.Contains("建议");
                    listBin.Add(new BinChoiceData() { tag = int.Parse(settingPathcvi_1.Tag.ToString()), BinName = SettingList_Help.SetTips128[16].Tips, isShow = !txtlabcvi_1.Text.Contains("建议")});
                    txtlabcvi_2.Text = string.IsNullOrEmpty(SettingList_Help.SetTips128[17].Tips) ? "建议不放" : SettingList_Help.SetTips128[17].Tips;
                    cvipage2.Visible = !txtlabcvi_2.Text.Contains("建议");
                    listBin.Add(new BinChoiceData() { tag = int.Parse(settingPathcvi_2.Tag.ToString()), BinName = SettingList_Help.SetTips128[17].Tips, isShow = !txtlabcvi_2.Text.Contains("建议") });
                    txtlabcvi_3.Text = string.IsNullOrEmpty(SettingList_Help.SetTips128[18].Tips) ? "建议不放" : SettingList_Help.SetTips128[18].Tips;
                    cvipage3.Visible = !txtlabcvi_3.Text.Contains("建议");
                    listBin.Add(new BinChoiceData() { tag = int.Parse(settingPathcvi_3.Tag.ToString()), BinName = SettingList_Help.SetTips128[18].Tips, isShow = !txtlabcvi_3.Text.Contains("建议")  });
                    txtlabcvi_4.Text = string.IsNullOrEmpty(SettingList_Help.SetTips128[19].Tips) ? "建议不放" : SettingList_Help.SetTips128[19].Tips;
                    cvipage4.Visible = !txtlabcvi_4.Text.Contains("建议");
                    listBin.Add(new BinChoiceData() { tag = int.Parse(settingPathcvi_4.Tag.ToString()), BinName = SettingList_Help.SetTips128[19].Tips, isShow = !txtlabcvi_4.Text.Contains("建议") });
                    txtlabcvi_5.Text = string.IsNullOrEmpty(SettingList_Help.SetTips128[20].Tips) ? "建议不放" : SettingList_Help.SetTips128[20].Tips;
                    cvipage5.Visible = !txtlabcvi_5.Text.Contains("建议");
                    listBin.Add(new BinChoiceData() { tag = int.Parse(settingPathcvi_5.Tag.ToString()), BinName = SettingList_Help.SetTips128[20].Tips, isShow = !txtlabcvi_5.Text.Contains("建议")  });
                    txtlabcvi_6.Text = string.IsNullOrEmpty(SettingList_Help.SetTips128[21].Tips) ? "建议不放" : SettingList_Help.SetTips128[21].Tips;
                    cvipage6.Visible = !txtlabcvi_6.Text.Contains("建议");
                    listBin.Add(new BinChoiceData() { tag = int.Parse(settingPathcvi_6.Tag.ToString()), BinName = SettingList_Help.SetTips128[21].Tips, isShow = !txtlabcvi_6.Text.Contains("建议") });
                    txtlabcvi_7.Text = string.IsNullOrEmpty(SettingList_Help.SetTips128[22].Tips) ? "建议不放" : SettingList_Help.SetTips128[22].Tips;
                    cvipage7.Visible = !txtlabcvi_7.Text.Contains("建议");
                    listBin.Add(new BinChoiceData() { tag = int.Parse(settingPathcvi_7.Tag.ToString()), BinName = SettingList_Help.SetTips128[22].Tips, isShow = !txtlabcvi_7.Text.Contains("建议")});
                    txtlabcvi_8.Text = string.IsNullOrEmpty(SettingList_Help.SetTips128[23].Tips) ? "建议不放" : SettingList_Help.SetTips128[23].Tips;
                    cvipage8.Visible = !txtlabcvi_8.Text.Contains("建议");
                    listBin.Add(new BinChoiceData() { tag = int.Parse(settingPathcvi_8.Tag.ToString()), BinName = SettingList_Help.SetTips128[23].Tips, isShow = !txtlabcvi_8.Text.Contains("建议") });
                    if (SettingList_Help.SetTips128.Count(c => c.Mode == SettingList_Help.SetTips128[16].Mode && !string.IsNullOrEmpty(c.Tips)) <= 0)
                    {
                        chdPage.PageVisible = false;
                        navigationPane1.SelectedPage = cvbsPage;
                    }
                }
                else {
                    chdPage.PageVisible = false;
                }

                if (!string.IsNullOrEmpty(SettingList_Help.SetTips128[24].Mode))
                {
                    cvbsPage.Caption = $"{SettingList_Help.SetTips128[24].Mode}配置";
                    txtlabcvbs_1.Text = string.IsNullOrEmpty(SettingList_Help.SetTips128[24].Tips) ? "建议不放" : SettingList_Help.SetTips128[24].Tips;
                    cvbspage1.Visible = !txtlabcvbs_1.Text.Contains("建议");
                    listBin.Add(new BinChoiceData() { tag = int.Parse(settingPathcvbs_1.Tag.ToString()), BinName = SettingList_Help.SetTips128[24].Tips, isShow = !txtlabcvbs_1.Text.Contains("建议")  });
                    txtlabcvbs_2.Text = string.IsNullOrEmpty(SettingList_Help.SetTips128[25].Tips) ? "建议不放" : SettingList_Help.SetTips128[25].Tips;
                    cvbspage2.Visible = !txtlabcvbs_2.Text.Contains("建议");
                    listBin.Add(new BinChoiceData() { tag = int.Parse(settingPathcvbs_2.Tag.ToString()), BinName = SettingList_Help.SetTips128[25].Tips, isShow = !txtlabcvbs_2.Text.Contains("建议")  });
                    txtlabcvbs_3.Text = string.IsNullOrEmpty(SettingList_Help.SetTips128[26].Tips) ? "建议不放" : SettingList_Help.SetTips128[26].Tips;
                    cvbspage3.Visible = !txtlabcvbs_3.Text.Contains("建议");
                    listBin.Add(new BinChoiceData() { tag = int.Parse(settingPathcvbs_3.Tag.ToString()), BinName = SettingList_Help.SetTips128[26].Tips, isShow = !txtlabcvbs_3.Text.Contains("建议")  });
                    txtlabcvbs_4.Text = string.IsNullOrEmpty(SettingList_Help.SetTips128[27].Tips) ? "建议不放" : SettingList_Help.SetTips128[27].Tips;
                    cvbspage4.Visible = !txtlabcvbs_4.Text.Contains("建议");
                    listBin.Add(new BinChoiceData() { tag = int.Parse(settingPathcvbs_4.Tag.ToString()), BinName = SettingList_Help.SetTips128[27].Tips, isShow = !txtlabcvbs_4.Text.Contains("建议")  });
                    txtlabcvbs_5.Text = string.IsNullOrEmpty(SettingList_Help.SetTips128[28].Tips) ? "建议不放" : SettingList_Help.SetTips128[28].Tips;
                    cvbspage5.Visible = !txtlabcvbs_5.Text.Contains("建议");
                    listBin.Add(new BinChoiceData() { tag = int.Parse(settingPathcvbs_5.Tag.ToString()), BinName = SettingList_Help.SetTips128[28].Tips, isShow = !txtlabcvbs_5.Text.Contains("建议")  });
                    txtlabcvbs_6.Text = string.IsNullOrEmpty(SettingList_Help.SetTips128[29].Tips) ? "建议不放" : SettingList_Help.SetTips128[29].Tips;
                    cvbspage6.Visible = !txtlabcvbs_6.Text.Contains("建议");
                    listBin.Add(new BinChoiceData() { tag = int.Parse(settingPathcvbs_6.Tag.ToString()), BinName = SettingList_Help.SetTips128[29].Tips, isShow = !txtlabcvbs_6.Text.Contains("建议")  });
                    txtlabcvbs_7.Text = string.IsNullOrEmpty(SettingList_Help.SetTips128[30].Tips) ? "建议不放" : SettingList_Help.SetTips128[30].Tips;
                    cvbspage7.Visible = !txtlabcvbs_7.Text.Contains("建议");
                    listBin.Add(new BinChoiceData() { tag = int.Parse(settingPathcvbs_7.Tag.ToString()), BinName = SettingList_Help.SetTips128[30].Tips, isShow = !txtlabcvbs_7.Text.Contains("建议")  });
                    txtlabcvbs_8.Text = string.IsNullOrEmpty(SettingList_Help.SetTips128[31].Tips) ? "建议不放" : SettingList_Help.SetTips128[31].Tips;
                    cvbspage8.Visible = !txtlabcvbs_8.Text.Contains("建议");
                    listBin.Add(new BinChoiceData() { tag = int.Parse(settingPathcvbs_8.Tag.ToString()), BinName = SettingList_Help.SetTips128[31].Tips, isShow = !txtlabcvbs_8.Text.Contains("建议")  });
                    if (SettingList_Help.SetTips128.Count(c => c.Mode == SettingList_Help.SetTips128[24].Mode && !string.IsNullOrEmpty(c.Tips)) <= 0)
                    {
                        cvbsPage.PageVisible = false;
                        navigationPane1.SelectedPage = ahdPage;
                    }
                }
                else {
                    cvbsPage.PageVisible = false;
                }
                if (ahdPage.PageVisible)
                {
                    navigationPane1.SelectedPage = ahdPage;
                }
                else if (thdPage.PageVisible)
                {
                    navigationPane1.SelectedPage = thdPage;
                }
                else if (chdPage.PageVisible)
                {
                    navigationPane1.SelectedPage = chdPage;
                }
                else if (cvbsPage.PageVisible)
                {
                    navigationPane1.SelectedPage = cvbsPage;
                }
                

            }
            #endregion
            List<TreeListValue> listC = new List<TreeListValue>();
            for (int i = 0; i < SettingList_Help.SetTips128.Count; i++)
            {
                if (!string.IsNullOrEmpty(SettingList_Help.SetTips128[i].Tips))
                {
                    listC.Add(new TreeListValue { ValueMember = SettingList_Help.SetTips128[i].SettingNo, DisplayMember = SettingList_Help.SetTips128[i].Tips });
                }
               
            }
           
            #region 界面显示配置
            var model99 = Bincurrency_BLL.GetSingle(c => c.GuidId == GuidNo && c.BinId == 117);
            if (model99 != null)
            {
                isloadAgain = true;
                commonList = new List<TreeListValue>();
                commonList.Add(new TreeListValue { ValueMember = model99.BinInPath, DisplayMember = model99.BinInName });
                commonTxt.Properties.DataSource = commonList;
                commonTxt.EditValue = commonList.First().ValueMember;
                isloadAgain = false;
            }

            ///恢复上次选择
            var list = Bincurrency_BLL.GetListToDefault(GuidNo);
            isloadAgain = true;
            var model00 = list.Where(c => c.BinId == 112);
            foreach (var item in model00)
            {
                var idex =  SettingList_Help.SetTips128.FindIndex(c => c.SettingNo == item.SerialNo.ToString());
                ReSetSettingPath((int)item.SerialNo, new List<TreeListValue> { new TreeListValue { ValueMember = item.BinInPath, DisplayMember = item.BinInName } });
            }
            isloadAgain = false;


            #endregion


            #region 配置提示
            toolTipC.AutoPopDelay = 5000;
            toolTipC.InitialDelay = 0;
            toolTipC.ReshowDelay = 500;
            var iqStr = "只更新10.1 IQ_common参数值";
            var osStr = "更新整个setting参数值";
            toolTipC.SetToolTip(iqahdbtn1, iqStr);
            toolTipC.SetToolTip(iqahdbtn2, iqStr);
            toolTipC.SetToolTip(iqahdbtn3, iqStr);
            toolTipC.SetToolTip(iqahdbtn4, iqStr);
            toolTipC.SetToolTip(iqahdbtn5, iqStr);
            toolTipC.SetToolTip(iqahdbtn6, iqStr);
            toolTipC.SetToolTip(iqahdbtn7, iqStr);
            toolTipC.SetToolTip(iqahdbtn8, iqStr);
            toolTipC.SetToolTip(iqtvibtn1, iqStr);
            toolTipC.SetToolTip(iqtvibtn2, iqStr);
            toolTipC.SetToolTip(iqtvibtn3, iqStr);
            toolTipC.SetToolTip(iqtvibtn4, iqStr);
            toolTipC.SetToolTip(iqtvibtn5, iqStr);
            toolTipC.SetToolTip(iqtvibtn6, iqStr);
            toolTipC.SetToolTip(iqtvibtn7, iqStr);
            toolTipC.SetToolTip(iqtvibtn8, iqStr);
            toolTipC.SetToolTip(iqcvibtn1, iqStr);
            toolTipC.SetToolTip(iqcvibtn2, iqStr);
            toolTipC.SetToolTip(iqcvibtn3, iqStr);
            toolTipC.SetToolTip(iqcvibtn4, iqStr);
            toolTipC.SetToolTip(iqcvibtn5, iqStr);
            toolTipC.SetToolTip(iqcvibtn6, iqStr);
            toolTipC.SetToolTip(iqcvibtn7, iqStr);
            toolTipC.SetToolTip(iqcvibtn8, iqStr);
            toolTipC.SetToolTip(iqcvbsbtn1, iqStr);
            toolTipC.SetToolTip(iqcvbsbtn2, iqStr);
            toolTipC.SetToolTip(iqcvbsbtn3, iqStr);
            toolTipC.SetToolTip(iqcvbsbtn4, iqStr);
            toolTipC.SetToolTip(iqcvbsbtn5, iqStr);
            toolTipC.SetToolTip(iqcvbsbtn6, iqStr);
            toolTipC.SetToolTip(iqcvbsbtn7, iqStr);
            toolTipC.SetToolTip(iqcvbsbtn8, iqStr);

            toolTipC.SetToolTip(IQ_ComBtn, osStr);
            toolTipC.SetToolTip(osahdbtn1, osStr);
            toolTipC.SetToolTip(osahdbtn2, osStr);
            toolTipC.SetToolTip(osahdbtn3, osStr);
            toolTipC.SetToolTip(osahdbtn4, osStr);
            toolTipC.SetToolTip(osahdbtn5, osStr);
            toolTipC.SetToolTip(osahdbtn6, osStr);
            toolTipC.SetToolTip(osahdbtn7, osStr);
            toolTipC.SetToolTip(osahdbtn8, osStr);
            toolTipC.SetToolTip(ostvibtn1, osStr);
            toolTipC.SetToolTip(ostvibtn2, osStr);
            toolTipC.SetToolTip(ostvibtn3, osStr);
            toolTipC.SetToolTip(ostvibtn4, osStr);
            toolTipC.SetToolTip(ostvibtn5, osStr);
            toolTipC.SetToolTip(ostvibtn6, osStr);
            toolTipC.SetToolTip(ostvibtn7, osStr);
            toolTipC.SetToolTip(ostvibtn8, osStr);
            toolTipC.SetToolTip(oscvibtn1, osStr);
            toolTipC.SetToolTip(oscvibtn2, osStr);
            toolTipC.SetToolTip(oscvibtn3, osStr);
            toolTipC.SetToolTip(oscvibtn4, osStr);
            toolTipC.SetToolTip(oscvibtn5, osStr);
            toolTipC.SetToolTip(oscvibtn6, osStr);
            toolTipC.SetToolTip(oscvibtn7, osStr);
            toolTipC.SetToolTip(oscvibtn8, osStr);
            toolTipC.SetToolTip(oscvbsbtn1, osStr);
            toolTipC.SetToolTip(oscvbsbtn2, osStr);
            toolTipC.SetToolTip(oscvbsbtn3, osStr);
            toolTipC.SetToolTip(oscvbsbtn4, osStr);
            toolTipC.SetToolTip(oscvbsbtn5, osStr);
            toolTipC.SetToolTip(oscvbsbtn6, osStr);
            toolTipC.SetToolTip(oscvbsbtn7, osStr);
            toolTipC.SetToolTip(oscvbsbtn8, osStr);
            #endregion

            bianhaoLook.Properties.DataSource = listC;
            bianhaoLook.ItemIndex = -1;

        }

        void SetLookEditTag(int One, int Two, int Three, int Four) {
            if (isOsd) //osd  按照 来
            {
                settingPathahd_1.Tag = One + 0;
                settingPathahd_2.Tag = int.Parse( settingPathahd_1.Tag.ToString()) + 4;
                settingPathahd_3.Tag = int.Parse(settingPathahd_2.Tag.ToString()) + 4;
                settingPathahd_4.Tag = int.Parse(settingPathahd_3.Tag.ToString()) + 4;
                settingPathahd_5.Tag = int.Parse(settingPathahd_4.Tag.ToString()) + 4;
                settingPathahd_6.Tag = int.Parse(settingPathahd_5.Tag.ToString()) + 4;
                settingPathahd_7.Tag = int.Parse(settingPathahd_6.Tag.ToString()) + 4;
                settingPathahd_8.Tag = int.Parse(settingPathahd_7.Tag.ToString()) + 4;

                settingPathtvi_1.Tag = Two + 0;
                settingPathtvi_2.Tag = int.Parse(settingPathtvi_1.Tag.ToString()) + 4;
                settingPathtvi_3.Tag = int.Parse(settingPathtvi_2.Tag.ToString()) + 4;
                settingPathtvi_4.Tag = int.Parse(settingPathtvi_3.Tag.ToString()) + 4;
                settingPathtvi_5.Tag = int.Parse(settingPathtvi_4.Tag.ToString()) + 4;
                settingPathtvi_6.Tag = int.Parse(settingPathtvi_5.Tag.ToString()) + 4;
                settingPathtvi_7.Tag = int.Parse(settingPathtvi_6.Tag.ToString()) + 4;
                settingPathtvi_8.Tag = int.Parse(settingPathtvi_7.Tag.ToString()) + 4;

                settingPathcvi_1.Tag = Three + 0;
                settingPathcvi_2.Tag = int.Parse(settingPathcvi_1.Tag.ToString()) + 4;
                settingPathcvi_3.Tag = int.Parse(settingPathcvi_2.Tag.ToString()) + 4;
                settingPathcvi_4.Tag = int.Parse(settingPathcvi_3.Tag.ToString()) + 4;
                settingPathcvi_5.Tag = int.Parse(settingPathcvi_4.Tag.ToString()) + 4;
                settingPathcvi_6.Tag = int.Parse(settingPathcvi_5.Tag.ToString()) + 4;
                settingPathcvi_7.Tag = int.Parse(settingPathcvi_6.Tag.ToString()) + 4;
                settingPathcvi_8.Tag = int.Parse(settingPathcvi_7.Tag.ToString()) + 4;

                settingPathcvbs_1.Tag = Four + 0;
                settingPathcvbs_2.Tag = int.Parse(settingPathcvbs_1.Tag.ToString()) + 4;
                settingPathcvbs_3.Tag = int.Parse(settingPathcvbs_2.Tag.ToString()) + 4;
                settingPathcvbs_4.Tag = int.Parse(settingPathcvbs_3.Tag.ToString()) + 4;
                settingPathcvbs_5.Tag = int.Parse(settingPathcvbs_4.Tag.ToString()) + 4;
                settingPathcvbs_6.Tag = int.Parse(settingPathcvbs_5.Tag.ToString()) + 4;
                settingPathcvbs_7.Tag = int.Parse(settingPathcvbs_6.Tag.ToString()) + 4;
                settingPathcvbs_8.Tag = int.Parse(settingPathcvbs_7.Tag.ToString()) + 4;
            }
            else {
                settingPathahd_1.Tag = One+0;
                settingPathahd_2.Tag = One+1;
                settingPathahd_3.Tag = One+2;
                settingPathahd_4.Tag = One+3;
                settingPathahd_5.Tag = One+4;
                settingPathahd_6.Tag = One+5;
                settingPathahd_7.Tag = One+6;
                settingPathahd_8.Tag = One+7;

                settingPathtvi_1.Tag = Two+0;
                settingPathtvi_2.Tag = Two+1;
                settingPathtvi_3.Tag = Two+2;
                settingPathtvi_4.Tag = Two+3;
                settingPathtvi_5.Tag = Two+4;
                settingPathtvi_6.Tag = Two+5;
                settingPathtvi_7.Tag = Two+6;
                settingPathtvi_8.Tag = Two+7;

                settingPathcvi_1.Tag = Three+0;
                settingPathcvi_2.Tag = Three+1;
                settingPathcvi_3.Tag = Three+2;
                settingPathcvi_4.Tag = Three+3;
                settingPathcvi_5.Tag = Three+4;
                settingPathcvi_6.Tag = Three+5;
                settingPathcvi_7.Tag = Three+6;
                settingPathcvi_8.Tag = Three + 7;

                settingPathcvbs_1.Tag = Four+0;
                settingPathcvbs_2.Tag = Four+1;
                settingPathcvbs_3.Tag = Four+2;
                settingPathcvbs_4.Tag = Four+3;
                settingPathcvbs_5.Tag = Four+4;
                settingPathcvbs_6.Tag = Four+5;
                settingPathcvbs_7.Tag = Four+6;
                settingPathcvbs_8.Tag = Four + 7;
            }
        }

        #region 再次进来时设置下拉框  根据tag进行数据筛选   有无osd 应该都可行  osd 目前没有测试
        /// <summary>
        ///再次进来时设置下拉框
        /// </summary>
        private void ReSetSettingPath(int num, List<TreeListValue> data)
        {

            ///osd 情况虾  这个功能暂时放着  写osd 在编写此处逻辑
            /// 
            if (num == int.Parse(settingPathahd_1.Tag.ToString()))//ahd
            {
                settingPathahd_1.Properties.DataSource = data; settingPathahd_1.ItemIndex = 0;
            }
            else if (num == int.Parse(settingPathahd_2.Tag.ToString()))
            {
                settingPathahd_2.Properties.DataSource = data; settingPathahd_2.ItemIndex = 0;
            }
            else if (num == int.Parse(settingPathahd_3.Tag.ToString()))
            {
                settingPathahd_3.Properties.DataSource = data; settingPathahd_3.ItemIndex = 0;
            }
            else if (num == int.Parse(settingPathahd_4.Tag.ToString()))
            {
                settingPathahd_4.Properties.DataSource = data; settingPathahd_4.ItemIndex = 0;
            }
            else if (num == int.Parse(settingPathahd_5.Tag.ToString()))
            {
                settingPathahd_5.Properties.DataSource = data; settingPathahd_5.ItemIndex = 0;
            }
            else if (num == int.Parse(settingPathahd_6.Tag.ToString()))
            {
                settingPathahd_6.Properties.DataSource = data; settingPathahd_6.ItemIndex = 0;
            }
            else if (num == int.Parse(settingPathahd_7.Tag.ToString()))
            {
                settingPathahd_7.Properties.DataSource = data; settingPathahd_7.ItemIndex = 0;
            }
            else if (num == int.Parse(settingPathahd_8.Tag.ToString()))
            {
                settingPathahd_8.Properties.DataSource = data; settingPathahd_8.ItemIndex = 0;
            }
            else if (num == int.Parse(settingPathtvi_1.Tag.ToString())) //THD
            {
                settingPathtvi_1.Properties.DataSource = data; settingPathtvi_1.ItemIndex = 0;
            }
            else if (num == int.Parse(settingPathtvi_2.Tag.ToString()))
            {
                settingPathtvi_2.Properties.DataSource = data; settingPathtvi_2.ItemIndex = 0;
            }
            else if (num == int.Parse(settingPathtvi_3.Tag.ToString()))
            {
                settingPathtvi_3.Properties.DataSource = data; settingPathtvi_3.ItemIndex = 0;
            }
            else if (num == int.Parse(settingPathtvi_4.Tag.ToString()))
            {
                settingPathtvi_4.Properties.DataSource = data; settingPathtvi_4.ItemIndex = 0;
            }
            else if (num == int.Parse(settingPathtvi_5.Tag.ToString()))
            {
                settingPathtvi_5.Properties.DataSource = data; settingPathtvi_5.ItemIndex = 0;
            }
            else if (num == int.Parse(settingPathtvi_6.Tag.ToString()))
            {
                settingPathtvi_6.Properties.DataSource = data; settingPathtvi_6.ItemIndex = 0;
            }
            else if (num == int.Parse(settingPathtvi_7.Tag.ToString()))
            {
                settingPathtvi_7.Properties.DataSource = data; settingPathtvi_7.ItemIndex = 0;
            }
            else if (num == int.Parse(settingPathtvi_8.Tag.ToString()))
            {
                settingPathtvi_8.Properties.DataSource = data; settingPathtvi_8.ItemIndex = 0;
            }
            else if (num == int.Parse(settingPathcvi_1.Tag.ToString()))//chd
            {
                settingPathcvi_1.Properties.DataSource = data; settingPathcvi_1.ItemIndex = 0;
            }
            else if (num == int.Parse(settingPathcvi_2.Tag.ToString()))
            {
                settingPathcvi_2.Properties.DataSource = data; settingPathcvi_2.ItemIndex = 0;
            }
            else if (num == int.Parse(settingPathcvi_3.Tag.ToString()))
            {
                settingPathcvi_3.Properties.DataSource = data; settingPathcvi_3.ItemIndex = 0;
            }
            else if (num == int.Parse(settingPathcvi_4.Tag.ToString()))
            {
                settingPathcvi_4.Properties.DataSource = data; settingPathcvi_4.ItemIndex = 0;
            }
            else if (num == int.Parse(settingPathcvi_5.Tag.ToString()))
            {
                settingPathcvi_5.Properties.DataSource = data; settingPathcvi_5.ItemIndex = 0;
            }
            else if (num == int.Parse(settingPathcvi_6.Tag.ToString()))
            {
                settingPathcvi_6.Properties.DataSource = data; settingPathcvi_6.ItemIndex = 0;
            }
            else if (num == int.Parse(settingPathcvi_7.Tag.ToString()))
            {
                settingPathcvi_7.Properties.DataSource = data; settingPathcvi_7.ItemIndex = 0;
            }
            else if (num == int.Parse(settingPathcvi_8.Tag.ToString()))
            {
                settingPathcvi_8.Properties.DataSource = data; settingPathcvi_8.ItemIndex = 0;
            }
            else if (num == int.Parse(settingPathcvbs_1.Tag.ToString()))//cvbs
            {
                settingPathcvbs_1.Properties.DataSource = data; settingPathcvbs_1.ItemIndex = 0;
            }
            else if (num == int.Parse(settingPathcvbs_2.Tag.ToString()))
            {
                settingPathcvbs_2.Properties.DataSource = data; settingPathcvbs_2.ItemIndex = 0;
            }
            else if (num == int.Parse(settingPathcvbs_3.Tag.ToString()))
            {
                settingPathcvbs_3.Properties.DataSource = data; settingPathcvbs_3.ItemIndex = 0;
            }
            else if (num == int.Parse(settingPathcvbs_4.Tag.ToString()))
            {
                settingPathcvbs_4.Properties.DataSource = data; settingPathcvbs_4.ItemIndex = 0;
            }
            else if (num == int.Parse(settingPathcvbs_5.Tag.ToString()))
            {
                settingPathcvbs_5.Properties.DataSource = data; settingPathcvbs_5.ItemIndex = 0;
            }
            else if (num == int.Parse(settingPathcvbs_6.Tag.ToString()))
            {
                settingPathcvbs_6.Properties.DataSource = data; settingPathcvbs_6.ItemIndex = 0;
            }
            else if (num == int.Parse(settingPathcvbs_7.Tag.ToString()))
            {
                settingPathcvbs_7.Properties.DataSource = data; settingPathcvbs_7.ItemIndex = 0;
            }
            else if (num == int.Parse(settingPathcvbs_8.Tag.ToString()))
            {
                settingPathcvbs_8.Properties.DataSource = data; settingPathcvbs_8.ItemIndex = 0;
            }

        }
        #endregion




        private void setbtn1_Click(object sender, EventArgs e)
        {
            var btn = sender as DevExpress.XtraEditors.SimpleButton;
            try
            {
                var serialno = (int.Parse(btn.Tag.ToString()) - 1);
                OpenFileDialog openFileDialog1 = new OpenFileDialog();
                openFileDialog1.Filter = "TXT Files(*.txt;*.c)|*.txt;*.c|All Files(*.*)|*.*";
                if (openFileDialog1.ShowDialog() == DialogResult.OK)
                {
                    #region 32套文件勾选
                    switch (btn.Tag.ToString())
                    {
                        case "1":
                            {
                                SetLookEdit(openFileDialog1, serialno, settingPathahd_1);
                            }
                            break;
                        case "2":
                            {
                                SetLookEdit(openFileDialog1, serialno, settingPathahd_2);
                            }
                            break;
                        case "3":
                            {
                                SetLookEdit(openFileDialog1, serialno, settingPathahd_3);
                            }
                            break;
                        case "4":
                            {
                                SetLookEdit(openFileDialog1, serialno, settingPathahd_4);
                            }
                            break;
                        case "5":
                            {
                                SetLookEdit(openFileDialog1, serialno, settingPathahd_5);
                            }
                            break;
                        case "6":
                            {
                                SetLookEdit(openFileDialog1, serialno, settingPathahd_6);
                            }
                            break;
                        case "7":
                            {
                                SetLookEdit(openFileDialog1, serialno, settingPathahd_7);
                            }
                            break;
                        case "8":
                            {
                                SetLookEdit(openFileDialog1, serialno, settingPathahd_8);
                            }
                            break;
                        case "9":
                            {
                                SetLookEdit(openFileDialog1, serialno, settingPathtvi_1);
                            }
                            break;
                        case "10":
                            {
                                SetLookEdit(openFileDialog1, serialno, settingPathtvi_2);
                            }
                            break;
                        case "11":
                            {
                                SetLookEdit(openFileDialog1, serialno, settingPathtvi_3);
                            }
                            break;
                        case "12":
                            {
                                SetLookEdit(openFileDialog1, serialno, settingPathtvi_4);
                            }
                            break;
                        case "13":
                            {
                                SetLookEdit(openFileDialog1, serialno, settingPathtvi_5);
                            }
                            break;
                        case "14":
                            {
                                SetLookEdit(openFileDialog1, serialno, settingPathtvi_6);
                            }
                            break;
                        case "15":
                            {
                                SetLookEdit(openFileDialog1, serialno, settingPathtvi_7);
                            }
                            break;
                        case "16":
                            {
                                SetLookEdit(openFileDialog1, serialno, settingPathtvi_8);
                            }
                            break;
                        case "17":
                            {
                                SetLookEdit(openFileDialog1, serialno, settingPathcvi_1);
                            }
                            break;
                        case "18":
                            {
                                SetLookEdit(openFileDialog1, serialno, settingPathcvi_2);
                            }
                            break;
                        case "19":
                            {
                                SetLookEdit(openFileDialog1, serialno, settingPathcvi_3);
                            }
                            break;
                        case "20":
                            {
                                SetLookEdit(openFileDialog1, serialno, settingPathcvi_4);
                            }
                            break;
                        case "21":
                            {
                                SetLookEdit(openFileDialog1, serialno, settingPathcvi_5);
                            }
                            break;
                        case "22":
                            {
                                SetLookEdit(openFileDialog1, serialno, settingPathcvi_6);
                            }
                            break;
                        case "23":
                            {
                                SetLookEdit(openFileDialog1, serialno, settingPathcvi_7);
                            }
                            break;
                        case "24":
                            {
                                SetLookEdit(openFileDialog1, serialno, settingPathcvi_8);
                            }
                            break;
                        case "25":
                            {
                                SetLookEdit(openFileDialog1, serialno, settingPathcvbs_1);
                            }
                            break;
                        case "26":
                            {
                                SetLookEdit(openFileDialog1, serialno, settingPathcvbs_2);
                            }
                            break;
                        case "27":
                            {
                                SetLookEdit(openFileDialog1, serialno, settingPathcvbs_3);
                            }
                            break;
                        case "28":
                            {
                                SetLookEdit(openFileDialog1, serialno, settingPathcvbs_4);
                            }
                            break;
                        case "29":
                            {
                                SetLookEdit(openFileDialog1, serialno, settingPathcvbs_5);
                            }
                            break;
                        case "30":
                            {
                                SetLookEdit(openFileDialog1, serialno, settingPathcvbs_6);
                            }
                            break;
                        case "31":
                            {
                                SetLookEdit(openFileDialog1, serialno, settingPathcvbs_7);
                            }
                            break;
                        case "32":
                            {
                                SetLookEdit(openFileDialog1, serialno, settingPathcvbs_8);
                            }
                            break;
                        default:
                            break;
                    } 
                    #endregion
                }
            }
            catch
            {
                WaitBefore.Close();
                //WaitBeforeLogin.Invoke((EventHandler)delegate { WaitBeforeLogin.Close(); });
                GenerateFileHelp.Close_Process_ByAll();
            }
        }

        private static void SetLookEdit(OpenFileDialog openFileDialog1,int Num, DevExpress.XtraEditors.LookUpEdit setPath)
        {
            if (null == SettingList_Help.SetTips128[Num].data)
            {
                SettingList_Help.SetTips128[Num].data = new List<TreeListValue>();
            }
            //SettingList_Help.SetTips128[Num].Tag = Num.ToString();
            SettingList_Help.SetTips128[Num].data.Add(new TreeListValue() { ValueMember = openFileDialog1.FileName, DisplayMember = Path.GetFileName(openFileDialog1.FileName) });
            setPath.Properties.DataSource = SettingList_Help.SetTips128[Num].data;
            setPath.ItemIndex = SettingList_Help.SetTips128[Num].data.Count() - 1;
            //ParaHelp.Bin_Taoshi_Utc.Find(c => c.Note == SettingList_Help.SetTips128[Num].Tips).PValue = $"0x{Convert.ToInt32(SettingList_Help.SetTips128[Num].SettingNo).ToString("X2").PadLeft(2, '0')}";

        }

        private void settingPathtxt1_EditValueChanged(object sender, EventArgs e)
        {
            if (isloadAgain) return;
            var settingPath = sender as LookUpEdit;   
                   
            BinUpdate(settingPath.EditValue.ToString(), settingPath.Tag.ToString());
        }
        private void BinUpdate(string pathName, string orId)
        {
            if (!string.IsNullOrEmpty(pathName) && pathName != "请选择文件")
            {
                //var commonPath = OpenSettingToFile(pathName);
                ////0_0
                var model99 = Bincurrency_BLL.GetList(c => c.GuidId == GuidNo);
                var model00 = model99.First(c => c.Id == BinCur.Id && c.GuidId == GuidNo);
                var modelMax = model99.Where(c => c.BinId == model00.BinId).Max(c => c.SortOrder); //serialno 记录位置  sortorder记录排序

                if (!model99.Exists(c => c.BinId == model00.BinId && c.SerialNo == int.Parse(orId) && c.GuidId == GuidNo))
                {

                    var mode102 = new bincurrency();
                    mode102.GuidId = GuidNo;
                    mode102.BinId = model00.BinId;
                    mode102.CreateTime = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss");
                    mode102.BinInPath = pathName;
                    mode102.BinInName = Path.GetFileName(pathName);
                    
                    mode102.FileStatus = 2;
                    mode102.SerialNo = int.Parse(orId);
                    mode102.SortOrder = modelMax + 1;
                    mode102.IsModified = (mode102.SortOrder == 0 ? 0 : 1);
                    Bincurrency_BLL.Insert(mode102);
                    var modelT = model99.First(c => c.BinId == model00.BinId && c.GuidId == GuidNo && c.SerialNo == 0);
                    modelT.FileStatus = 2;
                    Bincurrency_BLL.Update(modelT);
                }
                else
                {
                    var mode101 = model99.First(c => c.BinId == model00.BinId && c.SerialNo == int.Parse(orId) && c.GuidId == GuidNo);
                    mode101.BinInPath = pathName;
                    mode101.BinInName = Path.GetFileName(pathName);
                   
                    mode101.FileStatus = 2;
                    mode101.SerialNo = int.Parse(orId);
                    //mode101.SortOrder = modelMax;
                    mode101.IsModified = (mode101.SortOrder == 0 ? 0 : 1);
                    Bincurrency_BLL.Update(mode101);
                }
            }
        }

        /// <summary>
        /// 打开文件
        /// </summary>
        /// <param name="openFile">文件路径</param>
        /// <returns></returns>
        public string OpenSettingToFile(string openFile)
        {
            string pSavePath = string.Format("{0}\\Lib\\xc{1}_setting\\", Application.StartupPath, ConfigurationManager.AppSettings["xcVersion"]);
            string pLocalName = System.IO.Path.GetFileName(openFile); //获取文件名
            string path = pSavePath + "\\Flash_" + Path.GetFileNameWithoutExtension(pLocalName) + ".txt";
            var rList = Setting2Help.ReadTextFileToList(openFile);
            if (isPollingSetOk)
            {
                if (isPress_key == 0)
                {
                    rList.AddRange(ParaHelp.CreateBinPressKey());
                    rList.Add("");
                    uint pin = Convert.ToUInt16(ParaHelp.Bin_Press_Key.Find(p => p.PKey == "0x0b38").PValue, 16);
                    List<string[]> tempList = new List<string[]>();
                    #region 解析rlist存入tempList
                    string addrPageH = "80";
                    string addrPageM = string.Empty;
                    foreach (string line in rList)
                    {
                        string[] temp = new string[3];
                        temp[0] = line;
                        string[] col = line.ToLower().Replace('，', ',').Split(',');
                        string colFirst = col.First().Trim();
                        if (col.Count() > 2)
                        {
                            if (colFirst == "0xfffd")
                            {
                                addrPageH = col[1].Replace("0x", "").Trim();
                            }
                            else if (colFirst == "0xfffe")
                            {
                                addrPageM = col[1].Replace("0x", "").Trim();
                            }
                            else if (colFirst.Contains("0x") && !colFirst.Contains("//"))
                            {
                                temp[1] = addrPageH + addrPageM + colFirst.Replace("0x", "").Replace(" ", "");
                                temp[2] = col[1].Replace("0x", "").Replace(" ", "");
                            }
                        }
                        tempList.Add(temp);
                    }
                    #endregion
                    #region 更新寄存器方法
                    Action<string, string> tempUpReg = new Action<string, string>(
                                 (string addr, string value) =>
                                 {
                                     string tempstr = tempList.LastOrDefault(c => c[1] == addr).First();
                                     string[] tempStrArray = tempstr.Replace("，", ",").Split(',');
                                     tempStrArray[1] = value;
                                     tempList.Last(c => c[1] == addr)[0] = string.Join(",", tempStrArray);
                                 });
                    #endregion
                    string gpio8_15_en = tempList.LastOrDefault(c => c[1] == "80500201")?.GetValue(2).ToString();
                    string gpio8_15_dir = tempList.LastOrDefault(c => c[1] == "80500205")?.GetValue(2).ToString();
                    string gpio8_15_in_en = tempList.LastOrDefault(c => c[1] == "805000d1")?.GetValue(2).ToString();
                    switch (pin)
                    {
                        #region 更新按键轮询所选gpio相关寄存器
                        case 0://Gpio 2
                            string gpio0_7_en = tempList.LastOrDefault(c => c[1] == "80500200")?.GetValue(2).ToString();
                            string gpio0_7_dir = tempList.LastOrDefault(c => c[1] == "80500204")?.GetValue(2).ToString();
                            string gpio0_7_in_en = tempList.LastOrDefault(c => c[1] == "805000d0")?.GetValue(2).ToString();
                            if (string.IsNullOrEmpty(gpio0_7_en) || string.IsNullOrEmpty(gpio0_7_dir) || string.IsNullOrEmpty(gpio0_7_in_en))
                            {
                                tempList.Add(new string[3] { "0xfffd,0x80,\r\n0xfffe,0x50,", null, null });
                            }
                            if (string.IsNullOrEmpty(gpio0_7_en))
                            {
                                tempList.Add(new string[3] { "0x0200,0x04,", null, null });
                            }
                            else
                            {
                                uint tempVal = Convert.ToUInt16(gpio0_7_en, 16);
                                tempUpReg("80500200", "0x" + (tempVal | 0x04).ToString("x2"));
                            }
                            if (string.IsNullOrEmpty(gpio0_7_dir))
                            {
                                tempList.Add(new string[3] { "0x0204,0x00,", null, null });
                            }
                            else
                            {
                                uint tempVal = Convert.ToUInt16(gpio0_7_dir, 16);
                                tempUpReg("80500204", "0x" + (tempVal & 0xfb).ToString("x2"));
                            }
                            if (string.IsNullOrEmpty(gpio0_7_in_en))
                            {
                                tempList.Add(new string[3] { "0x00d0,0x04,", null, null });
                            }
                            else
                            {
                                uint tempVal = Convert.ToUInt16(gpio0_7_in_en, 16);
                                tempUpReg("805000d0", "0x" + (tempVal | 0x04).ToString("x2"));
                            }
                            break;
                        case 1://Gpio 8                           
                            if (string.IsNullOrEmpty(gpio8_15_en) || string.IsNullOrEmpty(gpio8_15_dir) || string.IsNullOrEmpty(gpio8_15_in_en))
                            {
                                tempList.Add(new string[3] { "0xfffd,0x80,\r\n0xfffe,0x50,", null, null });
                            }
                            if (string.IsNullOrEmpty(gpio8_15_en))
                            {
                                tempList.Add(new string[3] { "0x0201,0x01,", null, null });
                            }
                            else
                            {
                                uint tempVal = Convert.ToUInt16(gpio8_15_en, 16);
                                tempUpReg("80500201", "0x" + (tempVal | 0x01).ToString("x2"));
                            }
                            if (string.IsNullOrEmpty(gpio8_15_dir))
                            {
                                tempList.Add(new string[3] { "0x0205,0x00,", null, null });
                            }
                            else
                            {
                                uint tempVal = Convert.ToUInt16(gpio8_15_dir, 16);
                                tempUpReg("80500205", "0x" + (tempVal & 0xfe).ToString("x2"));
                            }
                            if (string.IsNullOrEmpty(gpio8_15_in_en))
                            {
                                tempList.Add(new string[3] { "0x00d1,0x01,", null, null });
                            }
                            else
                            {
                                uint tempVal = Convert.ToUInt16(gpio8_15_in_en, 16);
                                tempUpReg("805000d1", "0x" + (tempVal | 0x01).ToString("x2"));
                            }
                            break;
                        case 2://Gpio 9
                            if (string.IsNullOrEmpty(gpio8_15_en) || string.IsNullOrEmpty(gpio8_15_dir) || string.IsNullOrEmpty(gpio8_15_in_en))
                            {
                                tempList.Add(new string[3] { "0xfffd,0x80,\r\n0xfffe,0x50,", null, null });
                            }
                            if (string.IsNullOrEmpty(gpio8_15_en))
                            {
                                tempList.Add(new string[3] { "0x0201,0x02,", null, null });
                            }
                            else
                            {
                                uint tempVal = Convert.ToUInt16(gpio8_15_en, 16);
                                tempUpReg("80500201", "0x" + (tempVal | 0x02).ToString("x2"));
                            }
                            if (string.IsNullOrEmpty(gpio8_15_dir))
                            {
                                tempList.Add(new string[3] { "0x0205,0x00,", null, null });
                            }
                            else
                            {
                                uint tempVal = Convert.ToUInt16(gpio8_15_dir, 16);
                                tempUpReg("80500205", "0x" + (tempVal & 0xfd).ToString("x2"));
                            }
                            if (string.IsNullOrEmpty(gpio8_15_in_en))
                            {
                                tempList.Add(new string[3] { "0x00d1,0x02,", null, null });
                            }
                            else
                            {
                                uint tempVal = Convert.ToUInt16(gpio8_15_in_en, 16);
                                tempUpReg("805000d1", "0x" + (tempVal | 0x02).ToString("x2"));
                            }
                            break;
                        case 3://Gpio 22
                            string gpio16_23_en = tempList.LastOrDefault(c => c[1] == "80500202")?.GetValue(2).ToString();
                            string gpio16_23_dir = tempList.LastOrDefault(c => c[1] == "80500206")?.GetValue(2).ToString();
                            string gpio16_23_in_en = tempList.LastOrDefault(c => c[1] == "805000d2")?.GetValue(2).ToString();
                            int x = tempList.FindLastIndex(c => c[1] == "805000d2");
                            if (string.IsNullOrEmpty(gpio16_23_en) || string.IsNullOrEmpty(gpio16_23_dir) || string.IsNullOrEmpty(gpio16_23_in_en))
                            {
                                tempList.Add(new string[3] { "0xfffd,0x80,\r\n0xfffe,0x50,", null, null });
                            }
                            if (string.IsNullOrEmpty(gpio16_23_en))
                            {
                                tempList.Add(new string[3] { "0x0202,0x40,", null, null });
                            }
                            else
                            {
                                uint tempVal = Convert.ToUInt16(gpio16_23_en, 16);
                                tempUpReg("80500202", "0x" + (tempVal | 0x40).ToString("x2"));
                            }
                            if (string.IsNullOrEmpty(gpio16_23_dir))
                            {
                                tempList.Add(new string[3] { "0x0206,0x00,", null, null });
                            }
                            else
                            {
                                uint tempVal = Convert.ToUInt16(gpio16_23_dir, 16);
                                tempUpReg("80500206", "0x" + (tempVal & 0xbf).ToString("x2"));
                            }
                            if (string.IsNullOrEmpty(gpio16_23_in_en))
                            {
                                tempList.Add(new string[3] { "0x00d2,0x40,", null, null });
                            }
                            else
                            {
                                uint tempVal = Convert.ToUInt16(gpio16_23_in_en, 16);
                                tempUpReg("805000d2", "0x" + (tempVal | 0x40).ToString("x2"));
                            }
                            break;
                        #endregion
                        default:
                            break;
                    }
                    rList = tempList.Select(c => c[0]).ToList();
                }
                else if (isPress_key == 1)
                {
                    rList.AddRange(ParaHelp.CreateBinADC());
                }
            }
            else {
                //添加轮询使能开关
                rList.Add("0xfffd,0x80,");
                rList.Add("0xfffe,0x14,");
                rList.Add("0x0b1e,0x00,");
            }
            //if (!isoSwitchingcheck.Checked)
            //{
                rList.AddRange(ParaHelp.CreateBinSwitchingPatch());
            //}

            rList.Add("");
            rList.AddRange(ParaHelp.CreateBinTaoshiUtc());
            if (isOsdVerCheck)
            {
                rList.AddRange(ParaHelp.CreateOsdVersionInfo());
            }
            string openpath = System.IO.Path.GetDirectoryName(pSavePath) + "\\Temp_" + Path.GetFileNameWithoutExtension(pLocalName) + ".txt";
            File.WriteAllLines(openpath, rList.ToArray());
            Setting2Help.FlashSetting2Flash(openpath, path, 1, 0, 0); //测试模式下 Usage FPGA  选择0； --东东发布的时候改 现在这个给你用
            return path;
        }

        

     
        void SetNumFirst(bool isNum, int Num)
        {
            panelNum.Visible = isNum;
            if (!isNum) return;
            List<TreeListValue> listNum = new List<TreeListValue>();
            for (int i = 0; i < 32; i++)
            {
                listNum.Add(new TreeListValue() { ValueMember = i.ToString(), DisplayMember = i.ToString() });
            }
            lookUpNum.Properties.DataSource = listNum;
            lookUpNum.ItemIndex = Num;
        }

        private void lookUpNum_EditValueChanged(object sender, EventArgs e)
        {
            var model99 = Bincurrency_BLL.GetList(c => c.GuidId == GuidNo);
            if (!model99.Exists(c => c.BinId == 112 && c.SerialNo == 0 && c.GuidId == GuidNo)) //binid 写死112
            {
                var mode102 = new bincurrency();
                mode102.GuidId = GuidNo;
                mode102.BinId = 112;
                mode102.BinAddressNo = lookUpNum.Text;
                mode102.BinAddressOutName = $"{lookUpNum.Text}.txt";
                mode102.SortOrder = 0;
                mode102.IsModified = (mode102.SortOrder == 0 ? 0 : 1);
                Bincurrency_BLL.Insert(mode102);
            }
            else
            {
                //更新
                var model = model99.First(c => c.BinId == 112 && c.SerialNo == 0 && c.GuidId == GuidNo);
                model.BinAddressNo = lookUpNum.Text;
                model.BinAddressOutName = $"{lookUpNum.Text}.txt";
                Bincurrency_BLL.Update(model);
            }
        }

        /// <summary>
        /// 轮询弹出窗体
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void simpleButton1_Click(object sender, EventArgs e)
        {
            if(isPress_key == 0)
            {//按键
                XChip_BinChoice xcbc = new XChip_BinChoice(isPress_key, listBin.Where(c => c.isShow == true).ToList());
                xcbc.StartPosition = FormStartPosition.CenterParent;
                xcbc.ShowDialog();
                fuzhi();
            }
            else if(isPress_key == 1)
            {//ADC
                XChip_ADCPollingForm xchip_adcPForm = new XChip_ADCPollingForm(listBin.Where(c => c.isShow == true).ToList());
                xchip_adcPForm.StartPosition = FormStartPosition.CenterParent;
                xchip_adcPForm.ShowDialog();
            }
            
        }

   

        private void panelControl1_MouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                beginMove = true;
                currentXPosition = MousePosition.X;
                currentYPosition = MousePosition.Y;
            }
        }

        private void panelControl1_MouseLeave(object sender, EventArgs e)
        {
           
        }

        private void panelControl1_MouseUp(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                currentXPosition = 0;
                currentYPosition = 0;
                beginMove = false;
            }
        }
        /// <summary>
        /// 最小化按钮
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void simpleButton2_Click(object sender, EventArgs e)
        {
            this.WindowState = FormWindowState.Minimized;
        }
        /// <summary>
        /// 关闭按钮
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void simpleButton1_Click_1(object sender, EventArgs e)
        {


            //根据文件判断填写准时模式制式
            var list = SettingList_Help.SetTips128.Where(c => null !=c.data && c.data.Count>0&&(c.patternNo !=-1&&c.formatNo !=-1)).ToList();
            var modelList = list.Select(c => c.Mode).Distinct().ToList();

            if (modelList.Count == 1)
            {
                ParaHelp.Bin_Switching_Patch.Find(c => c.PKey == "0x08b5").PValue = "0x00";

                var mlist1 = list.Where(c => c.Mode == modelList[0]).Select(c => c.formatNo);
                ParaHelp.Bin_Switching_Patch.Find(c => c.PKey == "0x01bc").PValue = $"0xFF";
                ParaHelp.Bin_Switching_Patch.Find(c => c.PKey == "0x01bd").PValue = $"0xFF";

                ParaHelp.Bin_Switching_Patch.Find(c => c.PKey == "0x0272").PValue = $"0xFF";
                ParaHelp.Bin_Switching_Patch.Find(c => c.PKey == "0x0273").PValue = $"0xFF";

                ParaHelp.Bin_Switching_Patch.Find(c => c.PKey == "0x01bc").PValue = $"0xFF";
                ParaHelp.Bin_Switching_Patch.Find(c => c.PKey == "0x01bd").PValue = $"0xFF";

                ParaHelp.Bin_Switching_Patch.Find(c => c.PKey == "0x062e").PValue = $"0xFF";
                ParaHelp.Bin_Switching_Patch.Find(c => c.PKey == "0x062f").PValue = $"0xFF";
            }
            else if (modelList.Count == 2)
            {
                ParaHelp.Bin_Switching_Patch.Find(c => c.PKey == "0x08b5").PValue = "0x01";

                var mlist1 = list.Where(c => c.Mode == modelList[0]).Select(c => c.formatNo);
                var mlist2 = list.Where(c => c.Mode == modelList[1]).Select(c => c.formatNo);
                if (mlist1.SequenceEqual(mlist2))
                {
                    ParaHelp.Bin_Switching_Patch.Find(c => c.PKey == "0x01bc").PValue = $"0x{(list.Find(c => c.Mode.Contains(modelList[0])).patternNo).ToString().PadLeft(2, '0')}";
                    ParaHelp.Bin_Switching_Patch.Find(c => c.PKey == "0x01bd").PValue = $"0x{(list.FindLast(c => c.Mode.Contains(modelList[1])).patternNo).ToString().PadLeft(2, '0')}";

                    ParaHelp.Bin_Switching_Patch.Find(c => c.PKey == "0x0272").PValue = $"0x{(list.Find(c => c.Mode.Contains(modelList[0])).formatNo).ToString().PadLeft(2, '0')}";
                    ParaHelp.Bin_Switching_Patch.Find(c => c.PKey == "0x0273").PValue = $"0x{(list.FindLast(c => c.Mode.Contains(modelList[1])).formatNo).ToString().PadLeft(2, '0')}";

                    ParaHelp.Bin_Switching_Patch.Find(c => c.PKey == "0x01bc").PValue = $"0xFF";
                    ParaHelp.Bin_Switching_Patch.Find(c => c.PKey == "0x01bd").PValue = $"0xFF";

                    ParaHelp.Bin_Switching_Patch.Find(c => c.PKey == "0x062e").PValue = $"0xFF";
                    ParaHelp.Bin_Switching_Patch.Find(c => c.PKey == "0x062f").PValue = $"0xFF";

                }
                else
                {
                    ParaHelp.Bin_Switching_Patch.Find(c => c.PKey == "0x01ba").PValue = $"0x{(list.Find(c => c.Mode.Contains(modelList[0])).patternNo).ToString().PadLeft(2, '0')}";
                    ParaHelp.Bin_Switching_Patch.Find(c => c.PKey == "0x01bb").PValue = $"0x{(list.FindLast(c => c.Mode.Contains(modelList[0])).patternNo).ToString().PadLeft(2, '0')}";

                    ParaHelp.Bin_Switching_Patch.Find(c => c.PKey == "0x0272").PValue = $"0x{(list.Find(c => c.Mode.Contains(modelList[0])).formatNo).ToString().PadLeft(2, '0')}";
                    ParaHelp.Bin_Switching_Patch.Find(c => c.PKey == "0x0273").PValue = $"0x{(list.FindLast(c => c.Mode.Contains(modelList[0])).formatNo).ToString().PadLeft(2, '0')}";

                    ParaHelp.Bin_Switching_Patch.Find(c => c.PKey == "0x01bc").PValue = $"0x{(list.Find(c => c.Mode.Contains(modelList[1])).patternNo).ToString().PadLeft(2, '0')}";
                    ParaHelp.Bin_Switching_Patch.Find(c => c.PKey == "0x01bd").PValue = $"0x{(list.FindLast(c => c.Mode.Contains(modelList[1])).patternNo).ToString().PadLeft(2, '0')}";

                    ParaHelp.Bin_Switching_Patch.Find(c => c.PKey == "0x076b").PValue = $"0x{(list.Find(c => c.Mode.Contains(modelList[1])).formatNo).ToString().PadLeft(2, '0')}";
                    ParaHelp.Bin_Switching_Patch.Find(c => c.PKey == "0x07d8").PValue = $"0x{(list.FindLast(c => c.Mode.Contains(modelList[1])).formatNo).ToString().PadLeft(2, '0')}";

                }

            }
            else if (modelList.Count == 3)
            {
                ParaHelp.Bin_Switching_Patch.Find(c => c.PKey == "0x08b5").PValue = "0x01";
                var mlist1 = list.Where(c => c.Mode == modelList[0]).Select(c => c.formatNo);
                var mlist2 = list.Where(c => c.Mode == modelList[1]).Select(c => c.formatNo);
                var mlist3 = list.Where(c => c.Mode == modelList[2]).Select(c => c.formatNo);
                if ((mlist1.SequenceEqual(mlist2)) && (mlist2.SequenceEqual(mlist3)))
                {
                    ParaHelp.Bin_Switching_Patch.Find(c => c.PKey == "0x01ba").PValue = $"0x{(list.Find(c => c.Mode.Contains(modelList[0])).patternNo).ToString().PadLeft(2, '0')}";
                    ParaHelp.Bin_Switching_Patch.Find(c => c.PKey == "0x01bb").PValue = $"0x{(list.FindLast(c => c.Mode.Contains(modelList[2])).patternNo).ToString().PadLeft(2, '0')}";

                    ParaHelp.Bin_Switching_Patch.Find(c => c.PKey == "0x0272").PValue = $"0x{(list.Find(c => c.Mode.Contains(modelList[0])).formatNo).ToString().PadLeft(2, '0')}";
                    ParaHelp.Bin_Switching_Patch.Find(c => c.PKey == "0x0273").PValue = $"0x{(list.FindLast(c => c.Mode.Contains(modelList[2])).formatNo).ToString().PadLeft(2, '0')}";

                    ParaHelp.Bin_Switching_Patch.Find(c => c.PKey == "0x01bc").PValue = $"0xFF";
                    ParaHelp.Bin_Switching_Patch.Find(c => c.PKey == "0x01bd").PValue = $"0xFF";

                    ParaHelp.Bin_Switching_Patch.Find(c => c.PKey == "0x062e").PValue = $"0xFF";
                    ParaHelp.Bin_Switching_Patch.Find(c => c.PKey == "0x062f").PValue = $"0xFF";
                }
                else if ((mlist1.SequenceEqual(mlist2)) && (!mlist2.SequenceEqual(mlist3)))
                {
                    ParaHelp.Bin_Switching_Patch.Find(c => c.PKey == "0x01ba").PValue = $"0x{(list.Find(c => c.Mode.Contains(modelList[0])).patternNo).ToString().PadLeft(2, '0')}";
                    ParaHelp.Bin_Switching_Patch.Find(c => c.PKey == "0x01bb").PValue = $"0x{(list.FindLast(c => c.Mode.Contains(modelList[1])).patternNo).ToString().PadLeft(2, '0')}";

                    ParaHelp.Bin_Switching_Patch.Find(c => c.PKey == "0x0272").PValue = $"0x{(list.Find(c => c.Mode.Contains(modelList[0])).formatNo).ToString().PadLeft(2, '0')}";
                    ParaHelp.Bin_Switching_Patch.Find(c => c.PKey == "0x0273").PValue = $"0x{(list.FindLast(c => c.Mode.Contains(modelList[1])).formatNo).ToString().PadLeft(2, '0')}";

                    ParaHelp.Bin_Switching_Patch.Find(c => c.PKey == "0x01bc").PValue = $"0x{(list.Find(c => c.Mode.Contains(modelList[2])).patternNo).ToString().PadLeft(2, '0')}";
                    ParaHelp.Bin_Switching_Patch.Find(c => c.PKey == "0x01bd").PValue = $"0x{(list.FindLast(c => c.Mode.Contains(modelList[2])).patternNo).ToString().PadLeft(2, '0')}";

                    ParaHelp.Bin_Switching_Patch.Find(c => c.PKey == "0x076b").PValue = $"0x{(list.Find(c => c.Mode.Contains(modelList[2])).formatNo).ToString().PadLeft(2, '0')}";
                    ParaHelp.Bin_Switching_Patch.Find(c => c.PKey == "0x07d8").PValue = $"0x{(list.FindLast(c => c.Mode.Contains(modelList[2])).formatNo).ToString().PadLeft(2, '0')}";

                    ParaHelp.Bin_Switching_Patch.Find(c => c.PKey == "0x062e").PValue = $"0xFF";
                    ParaHelp.Bin_Switching_Patch.Find(c => c.PKey == "0x062f").PValue = $"0xFF";
                }
                else if((!mlist1.SequenceEqual(mlist2)) && (mlist2.SequenceEqual(mlist3)))
                {
                    ParaHelp.Bin_Switching_Patch.Find(c => c.PKey == "0x01ba").PValue = $"0x{(list.Find(c => c.Mode.Contains(modelList[0])).patternNo).ToString().PadLeft(2, '0')}";
                    ParaHelp.Bin_Switching_Patch.Find(c => c.PKey == "0x01bb").PValue = $"0x{(list.FindLast(c => c.Mode.Contains(modelList[0])).patternNo).ToString().PadLeft(2, '0')}";

                    ParaHelp.Bin_Switching_Patch.Find(c => c.PKey == "0x0272").PValue = $"0x{(list.Find(c => c.Mode.Contains(modelList[0])).formatNo).ToString().PadLeft(2, '0')}";
                    ParaHelp.Bin_Switching_Patch.Find(c => c.PKey == "0x0273").PValue = $"0x{(list.FindLast(c => c.Mode.Contains(modelList[0])).formatNo).ToString().PadLeft(2, '0')}";

                    ParaHelp.Bin_Switching_Patch.Find(c => c.PKey == "0x01bc").PValue = $"0x{(list.Find(c => c.Mode.Contains(modelList[1])).patternNo).ToString().PadLeft(2, '0')}";
                    ParaHelp.Bin_Switching_Patch.Find(c => c.PKey == "0x01bd").PValue = $"0x{(list.FindLast(c => c.Mode.Contains(modelList[2])).patternNo).ToString().PadLeft(2, '0')}";

                    ParaHelp.Bin_Switching_Patch.Find(c => c.PKey == "0x076b").PValue = $"0x{(list.Find(c => c.Mode.Contains(modelList[1])).formatNo).ToString().PadLeft(2, '0')}";
                    ParaHelp.Bin_Switching_Patch.Find(c => c.PKey == "0x07d8").PValue = $"0x{(list.FindLast(c => c.Mode.Contains(modelList[2])).formatNo).ToString().PadLeft(2, '0')}";

                    ParaHelp.Bin_Switching_Patch.Find(c => c.PKey == "0x062e").PValue = $"0xFF";
                    ParaHelp.Bin_Switching_Patch.Find(c => c.PKey == "0x062f").PValue = $"0xFF";
                }
                else 
                {
                    ParaHelp.Bin_Switching_Patch.Find(c => c.PKey == "0x01ba").PValue = $"0x{(list.Find(c => c.Mode.Contains(modelList[0])).patternNo).ToString().PadLeft(2, '0')}";
                    ParaHelp.Bin_Switching_Patch.Find(c => c.PKey == "0x01bb").PValue = $"0x{(list.FindLast(c => c.Mode.Contains(modelList[0])).patternNo).ToString().PadLeft(2, '0')}";

                    ParaHelp.Bin_Switching_Patch.Find(c => c.PKey == "0x0272").PValue = $"0x{(list.Find(c => c.Mode.Contains(modelList[0])).formatNo).ToString().PadLeft(2, '0')}";
                    ParaHelp.Bin_Switching_Patch.Find(c => c.PKey == "0x0273").PValue = $"0x{(list.FindLast(c => c.Mode.Contains(modelList[0])).formatNo).ToString().PadLeft(2, '0')}";

                    ParaHelp.Bin_Switching_Patch.Find(c => c.PKey == "0x01bc").PValue = $"0x{(list.Find(c => c.Mode.Contains(modelList[1])).patternNo).ToString().PadLeft(2, '0')}";
                    ParaHelp.Bin_Switching_Patch.Find(c => c.PKey == "0x01bd").PValue = $"0x{(list.FindLast(c => c.Mode.Contains(modelList[1])).patternNo).ToString().PadLeft(2, '0')}";

                    ParaHelp.Bin_Switching_Patch.Find(c => c.PKey == "0x076b").PValue = $"0x{(list.Find(c => c.Mode.Contains(modelList[1])).formatNo).ToString().PadLeft(2, '0')}";
                    ParaHelp.Bin_Switching_Patch.Find(c => c.PKey == "0x07d8").PValue = $"0x{(list.FindLast(c => c.Mode.Contains(modelList[1])).formatNo).ToString().PadLeft(2, '0')}";


                    ParaHelp.Bin_Switching_Patch.Find(c => c.PKey == "0x062e").PValue = $"0x{(list.Find(c => c.Mode.Contains(modelList[2])).patternNo).ToString().PadLeft(2, '0')}";
                    ParaHelp.Bin_Switching_Patch.Find(c => c.PKey == "0x062f").PValue = $"0x{(list.FindLast(c => c.Mode.Contains(modelList[2])).patternNo).ToString().PadLeft(2, '0')}";

                    ParaHelp.Bin_Switching_Patch.Find(c => c.PKey == "0x0630").PValue = $"0x{(list.Find(c => c.Mode.Contains(modelList[2])).formatNo).ToString().PadLeft(2, '0')}";
                    ParaHelp.Bin_Switching_Patch.Find(c => c.PKey == "0x0631").PValue = $"0x{(list.FindLast(c => c.Mode.Contains(modelList[2])).formatNo).ToString().PadLeft(2, '0')}";

                }
            }
            else if (modelList.Count == 4)
            {
                ParaHelp.Bin_Switching_Patch.Find(c => c.PKey == "0x08b5").PValue = "0x01";
                var mlist1 = list.Where(c => c.Mode == modelList[0]).Select(c => c.formatNo);
                var mlist2 = list.Where(c => c.Mode == modelList[1]).Select(c => c.formatNo);
                var mlist3 = list.Where(c => c.Mode == modelList[2]).Select(c => c.formatNo);
                var mlist4 = list.Where(c => c.Mode == modelList[3]).Select(c => c.formatNo);

                if (mlist1.SequenceEqual(mlist2)&&mlist2.SequenceEqual(mlist3)&&!mlist3.SequenceEqual(mlist4))
                {
                    ParaHelp.Bin_Switching_Patch.Find(c => c.PKey == "0x01ba").PValue = $"0x{(list.Find(c => c.Mode.Contains(modelList[0])).patternNo).ToString().PadLeft(2, '0')}";
                    ParaHelp.Bin_Switching_Patch.Find(c => c.PKey == "0x01bb").PValue = $"0x{(list.FindLast(c => c.Mode.Contains(modelList[2])).patternNo).ToString().PadLeft(2, '0')}";

                    ParaHelp.Bin_Switching_Patch.Find(c => c.PKey == "0x0272").PValue = $"0x{(list.Find(c => c.Mode.Contains(modelList[0])).formatNo).ToString().PadLeft(2, '0')}";
                    ParaHelp.Bin_Switching_Patch.Find(c => c.PKey == "0x0273").PValue = $"0x{(list.FindLast(c => c.Mode.Contains(modelList[2])).formatNo).ToString().PadLeft(2, '0')}";

                    ParaHelp.Bin_Switching_Patch.Find(c => c.PKey == "0x01bc").PValue = $"0x{(list.Find(c => c.Mode.Contains(modelList[3])).patternNo).ToString().PadLeft(2, '0')}";
                    ParaHelp.Bin_Switching_Patch.Find(c => c.PKey == "0x01bd").PValue = $"0x{(list.FindLast(c => c.Mode.Contains(modelList[3])).patternNo).ToString().PadLeft(2, '0')}";

                    ParaHelp.Bin_Switching_Patch.Find(c => c.PKey == "0x076b").PValue = $"0x{(list.Find(c => c.Mode.Contains(modelList[3])).formatNo).ToString().PadLeft(2, '0')}";
                    ParaHelp.Bin_Switching_Patch.Find(c => c.PKey == "0x07d8").PValue = $"0x{(list.FindLast(c => c.Mode.Contains(modelList[3])).formatNo).ToString().PadLeft(2, '0')}";


                    ParaHelp.Bin_Switching_Patch.Find(c => c.PKey == "0x062e").PValue = $"0xFF";
                    ParaHelp.Bin_Switching_Patch.Find(c => c.PKey == "0x062f").PValue = $"0xFF";

                    ParaHelp.Bin_Switching_Patch.Find(c => c.PKey == "0x0630").PValue = $"0xFF";
                    ParaHelp.Bin_Switching_Patch.Find(c => c.PKey == "0x0631").PValue = $"0xFF";

                }
                else if (mlist1.SequenceEqual(mlist2) && !mlist2.SequenceEqual(mlist3) && !mlist3.SequenceEqual(mlist4))
                {
                    ParaHelp.Bin_Switching_Patch.Find(c => c.PKey == "0x01ba").PValue = $"0x{(list.Find(c => c.Mode.Contains(modelList[0])).patternNo).ToString().PadLeft(2, '0')}";
                    ParaHelp.Bin_Switching_Patch.Find(c => c.PKey == "0x01bb").PValue = $"0x{(list.FindLast(c => c.Mode.Contains(modelList[1])).patternNo).ToString().PadLeft(2, '0')}";

                    ParaHelp.Bin_Switching_Patch.Find(c => c.PKey == "0x0272").PValue = $"0x{(list.Find(c => c.Mode.Contains(modelList[0])).formatNo).ToString().PadLeft(2, '0')}";
                    ParaHelp.Bin_Switching_Patch.Find(c => c.PKey == "0x0273").PValue = $"0x{(list.FindLast(c => c.Mode.Contains(modelList[1])).formatNo).ToString().PadLeft(2, '0')}";

                    ParaHelp.Bin_Switching_Patch.Find(c => c.PKey == "0x01bc").PValue = $"0x{(list.Find(c => c.Mode.Contains(modelList[2])).patternNo).ToString().PadLeft(2, '0')}";
                    ParaHelp.Bin_Switching_Patch.Find(c => c.PKey == "0x01bd").PValue = $"0x{(list.FindLast(c => c.Mode.Contains(modelList[2])).patternNo).ToString().PadLeft(2, '0')}";

                    ParaHelp.Bin_Switching_Patch.Find(c => c.PKey == "0x076b").PValue = $"0x{(list.Find(c => c.Mode.Contains(modelList[2])).formatNo).ToString().PadLeft(2, '0')}";
                    ParaHelp.Bin_Switching_Patch.Find(c => c.PKey == "0x07d8").PValue = $"0x{(list.FindLast(c => c.Mode.Contains(modelList[2])).formatNo).ToString().PadLeft(2, '0')}";


                    ParaHelp.Bin_Switching_Patch.Find(c => c.PKey == "0x062e").PValue = $"0x{(list.Find(c => c.Mode.Contains(modelList[3])).patternNo).ToString().PadLeft(2, '0')}";
                    ParaHelp.Bin_Switching_Patch.Find(c => c.PKey == "0x062f").PValue = $"0x{(list.FindLast(c => c.Mode.Contains(modelList[3])).patternNo).ToString().PadLeft(2, '0')}";

                    ParaHelp.Bin_Switching_Patch.Find(c => c.PKey == "0x0630").PValue = $"0x{(list.Find(c => c.Mode.Contains(modelList[3])).formatNo).ToString().PadLeft(2, '0')}";
                    ParaHelp.Bin_Switching_Patch.Find(c => c.PKey == "0x0631").PValue = $"0x{(list.FindLast(c => c.Mode.Contains(modelList[3])).formatNo).ToString().PadLeft(2, '0')}";

                }
                else if (!mlist1.SequenceEqual(mlist2) && mlist2.SequenceEqual(mlist3) && !mlist3.SequenceEqual(mlist4))
                {
                    ParaHelp.Bin_Switching_Patch.Find(c => c.PKey == "0x01ba").PValue = $"0x{(list.Find(c => c.Mode.Contains(modelList[0])).patternNo).ToString().PadLeft(2, '0')}";
                    ParaHelp.Bin_Switching_Patch.Find(c => c.PKey == "0x01bb").PValue = $"0x{(list.FindLast(c => c.Mode.Contains(modelList[0])).patternNo).ToString().PadLeft(2, '0')}";

                    ParaHelp.Bin_Switching_Patch.Find(c => c.PKey == "0x0272").PValue = $"0x{(list.Find(c => c.Mode.Contains(modelList[0])).formatNo).ToString().PadLeft(2, '0')}";
                    ParaHelp.Bin_Switching_Patch.Find(c => c.PKey == "0x0273").PValue = $"0x{(list.FindLast(c => c.Mode.Contains(modelList[0])).formatNo).ToString().PadLeft(2, '0')}";

                    ParaHelp.Bin_Switching_Patch.Find(c => c.PKey == "0x01bc").PValue = $"0x{(list.Find(c => c.Mode.Contains(modelList[1])).patternNo).ToString().PadLeft(2, '0')}";
                    ParaHelp.Bin_Switching_Patch.Find(c => c.PKey == "0x01bd").PValue = $"0x{(list.FindLast(c => c.Mode.Contains(modelList[2])).patternNo).ToString().PadLeft(2, '0')}";

                    ParaHelp.Bin_Switching_Patch.Find(c => c.PKey == "0x076b").PValue = $"0x{(list.Find(c => c.Mode.Contains(modelList[1])).formatNo).ToString().PadLeft(2, '0')}";
                    ParaHelp.Bin_Switching_Patch.Find(c => c.PKey == "0x07d8").PValue = $"0x{(list.FindLast(c => c.Mode.Contains(modelList[2])).formatNo).ToString().PadLeft(2, '0')}";


                    ParaHelp.Bin_Switching_Patch.Find(c => c.PKey == "0x062e").PValue = $"0x{(list.Find(c => c.Mode.Contains(modelList[3])).patternNo).ToString().PadLeft(2, '0')}";
                    ParaHelp.Bin_Switching_Patch.Find(c => c.PKey == "0x062f").PValue = $"0x{(list.FindLast(c => c.Mode.Contains(modelList[3])).patternNo).ToString().PadLeft(2, '0')}";

                    ParaHelp.Bin_Switching_Patch.Find(c => c.PKey == "0x0630").PValue = $"0x{(list.Find(c => c.Mode.Contains(modelList[3])).formatNo).ToString().PadLeft(2, '0')}";
                    ParaHelp.Bin_Switching_Patch.Find(c => c.PKey == "0x0631").PValue = $"0x{(list.FindLast(c => c.Mode.Contains(modelList[3])).formatNo).ToString().PadLeft(2, '0')}";

                }
            }
            else
            {
                ParaHelp.Bin_Switching_Patch.Find(c => c.PKey == "0x08b5").PValue = "0x00";
            }

            if (isPress_key == 1)
            {
                if (!ParaHelp.Bin_ADC.Last().SaveMask)
                {
                    var result = XtraMessageBox.Show("未配置轮询,是否关闭？", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Error);
                    if (result == DialogResult.No)
                    {
                        return;
                    }
                }
                else
                {
                    isPollingSetOk = true;
                }
            }
            else if (isPress_key == 0)
            {
                if (!ParaHelp.Bin_ADC.Last().SaveMask)
                {
                    var result = XtraMessageBox.Show("未配置轮询,是否关闭？", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Error);
                    if (result == DialogResult.No)
                    {
                        return;
                    }
                }
                else
                {
                    isPollingSetOk = true;
                }
            }
            //此处逻辑需要更改
            //更新生成
            var model99 = Bincurrency_BLL.GetList(c => c.GuidId == GuidNo && c.BinId == 112);

            foreach (var item in model99)
            {
                if (string.IsNullOrEmpty(item.BinInPath))
                {
                    continue;
                }
                //加入com文件
                string pSavePath = string.Format("{0}\\Lib\\xc{1}_setting\\", Application.StartupPath, ConfigurationManager.AppSettings["xcVersion"]);
                string pLocalName = System.IO.Path.GetFileName(item.BinInPath); //获取文件名
                string path = pSavePath + $"\\IQCom_{ Path.GetFileNameWithoutExtension(pLocalName)}_{AppHelper.GetTimeStamp()}.txt";
                if (null != commonTxt.EditValue && !string.IsNullOrEmpty(commonTxt.EditValue.ToString()))
                {
                    List<string> AList = File.ReadAllLines(item.BinInPath, Encoding.Default).ToList();
                    List<string> BList = File.ReadAllLines(commonTxt.EditValue.ToString(), Encoding.Default).ToList();
                    int aStartIndex = AList.FindIndex(c => c.Contains("xchip_i2c_bypass_on_regs"));
                    if (aStartIndex == -1)
                    {
                        DevExpress.XtraEditors.XtraMessageBox.Show($"选择setting文件:{item.BinInPath}格式错误！", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);

                       return;
                    }
                    int bStartIndex = BList.FindIndex(c => c.Contains("#region config"));
                    if (bStartIndex == -1)
                    {
                        DevExpress.XtraEditors.XtraMessageBox.Show($"选择common文件格式错误！", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                    var ispath = FileHelper.ComMergeFiles(AList, BList, path, "xchip_i2c_bypass_on_regs", "#region config");
                }
                else {
                    path = item.BinInPath;
                }
               
                var commonPath = OpenSettingToFile(path);
                item.BinOutPath = commonPath;
                item.BinOutName = Path.GetFileName(commonPath);
                item.LengthAddress = HeaderHelper.FilePathLengthComplement(commonPath);
                item.FileStatus = 2;
                Bincurrency_BLL.Update(item);
            }

            ////关闭后更新
            if (null != SendBinSetClick)
            {
                SendBinSetClick(GuidNo,isPollingSetOk);
            }
            this.Close();
        }

        private void XChip_SecurityFile64_MouseMove(object sender, MouseEventArgs e)
        {
            if (beginMove)
            {
                this.Left += MousePosition.X - currentXPosition;
                this.Top += MousePosition.Y - currentYPosition;
                currentXPosition = MousePosition.X;
                currentYPosition = MousePosition.Y;
            }
        }

        private void SelectFolderButton_Click(object sender, EventArgs e)
        {
           
            FolderBrowserDialog dialog = new FolderBrowserDialog();
            dialog.Description = "请选择文件路径";
            dialog.SelectedPath = AppHelper.GetAppConfig("Folder_Road_Force");
            ///Folder_Road_Force
            if (dialog.ShowDialog() == DialogResult.OK)
            {
                //清空下拉框数据源
                ClearLookUpEditDataSource();
                string foldPath = dialog.SelectedPath;
                AppHelper.UpdateAppConfig("Folder_Road_Force", foldPath);
                ///*t*/extBox2.Text = foldPath;
                ///
               
                SetTipList();
            }
           
        }
        private void ClearLookUpEditDataSource()
        {
            settingPathahd_1.Properties.DataSource = null; settingPathahd_1.EditValue = string.Empty;
            settingPathahd_2.Properties.DataSource = null; settingPathahd_2.EditValue = string.Empty;
            settingPathahd_3.Properties.DataSource = null; settingPathahd_3.EditValue = string.Empty;
            settingPathahd_4.Properties.DataSource = null; settingPathahd_4.EditValue = string.Empty;
            settingPathahd_5.Properties.DataSource = null; settingPathahd_5.EditValue = string.Empty;
            settingPathahd_6.Properties.DataSource = null; settingPathahd_6.EditValue = string.Empty;
            settingPathahd_7.Properties.DataSource = null; settingPathahd_7.EditValue = string.Empty;
            settingPathahd_8.Properties.DataSource = null; settingPathahd_8.EditValue = string.Empty;
            settingPathtvi_1.Properties.DataSource = null; settingPathtvi_1.EditValue = string.Empty;
            settingPathtvi_2.Properties.DataSource = null; settingPathtvi_2.EditValue = string.Empty;
            settingPathtvi_3.Properties.DataSource = null; settingPathtvi_3.EditValue = string.Empty;
            settingPathtvi_4.Properties.DataSource = null; settingPathtvi_4.EditValue = string.Empty;
            settingPathtvi_5.Properties.DataSource = null; settingPathtvi_5.EditValue = string.Empty;
            settingPathtvi_6.Properties.DataSource = null; settingPathtvi_6.EditValue = string.Empty;
            settingPathtvi_7.Properties.DataSource = null; settingPathtvi_7.EditValue = string.Empty;
            settingPathtvi_8.Properties.DataSource = null; settingPathtvi_8.EditValue = string.Empty;
            settingPathcvi_1.Properties.DataSource = null; settingPathcvi_1.EditValue = string.Empty;
            settingPathcvi_2.Properties.DataSource = null; settingPathcvi_2.EditValue = string.Empty;
            settingPathcvi_3.Properties.DataSource = null; settingPathcvi_3.EditValue = string.Empty;
            settingPathcvi_4.Properties.DataSource = null; settingPathcvi_4.EditValue = string.Empty;
            settingPathcvi_5.Properties.DataSource = null; settingPathcvi_5.EditValue = string.Empty;
            settingPathcvi_6.Properties.DataSource = null; settingPathcvi_6.EditValue = string.Empty;
            settingPathcvi_7.Properties.DataSource = null; settingPathcvi_7.EditValue = string.Empty;
            settingPathcvi_8.Properties.DataSource = null; settingPathcvi_8.EditValue = string.Empty;
            settingPathcvbs_1.Properties.DataSource = null; settingPathcvbs_1.EditValue = string.Empty;
            settingPathcvbs_2.Properties.DataSource = null; settingPathcvbs_2.EditValue = string.Empty;
            settingPathcvbs_3.Properties.DataSource = null; settingPathcvbs_3.EditValue = string.Empty;
            settingPathcvbs_4.Properties.DataSource = null; settingPathcvbs_4.EditValue = string.Empty;
            settingPathcvbs_5.Properties.DataSource = null; settingPathcvbs_5.EditValue = string.Empty;
            settingPathcvbs_6.Properties.DataSource = null; settingPathcvbs_6.EditValue = string.Empty;
            settingPathcvbs_7.Properties.DataSource = null; settingPathcvbs_7.EditValue = string.Empty;
            settingPathcvbs_8.Properties.DataSource = null; settingPathcvbs_8.EditValue = string.Empty;
        }

        private void SetTipList()
        {
            var filePaths = Directory.GetFiles(AppHelper.GetAppConfig("Folder_Road_Force"), "*.txt").Concat(Directory.GetFiles(AppHelper.GetAppConfig("Folder_Road_Force"), "*.c")).ToArray();
            List<TreeListValue> tlvList = new List<TreeListValue>();
            foreach (var item in filePaths)
            {
                tlvList.Add(new TreeListValue { ValueMember = item, DisplayMember = Path.GetFileName(item), });
            }

            commonList = tlvList.Where(c => c.ValueMember.ToLower().Contains("xchip_common_setting")).ToList(); //文件和128进行区分
            if (null == commonList || commonList.Count() <= 0)
            {
                DevExpress.XtraEditors.XtraMessageBox.Show($"文件夹中不存在\"xchip_common_setting\"文件", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            commonTxt.Properties.DataSource = commonList;
            //commonTxt.ItemIndex = comList.Count() > 1 ? -1 : 0;//itemindex赋过正值后，无法赋成-1，原因未知
            //commonTxt.EditValue = null;
            commonTxt.EditValue = commonList.Count() > 1 ? string.Empty : commonList.First().ValueMember;
            //isloadAgain = true;
            //存储未找到的文件
            List<string> noFoundFileList = new List<string>();
            for (int i = 0; i < SettingList_Help.SetTips128.Count; i++)
            {
                //if (i > 7 && SettingList_Help.SetTips[i].Tips.Contains("cvbs"))
                //{
                //    continue;
                //}
                if (i == 23)
                {

                }
                int settingNo;
                int.TryParse(SettingList_Help.SetTips128[i].SettingNo,out settingNo);
                if (null != SettingList_Help.SetTips128[i].data)
                {
                    var listTips = tlvList.Where(c => SettingList_Help.SetTips128[i].MatchName.Any(s => c.ValueMember.Contains(s))).ToList().Union(SettingList_Help.SetTips128[i].data).Distinct(new TrLComparer()).ToList();
                    SettingList_Help.SetTips128[i].data = listTips;
                   
                }
                else {
                    SettingList_Help.SetTips128[i].data = tlvList.Where(c => SettingList_Help.SetTips128[i].MatchName.Any(s => c.ValueMember.Contains(s))).ToList();
                }
                if (!string.IsNullOrEmpty(SettingList_Help.SetTips128[i].Tips) && (null == SettingList_Help.SetTips128[i].data || SettingList_Help.SetTips128[i].data.Count() == 0))
                {
                    noFoundFileList.Add($"{ SettingList_Help.SetTips128[i].Tips}、{ string.Join("或", SettingList_Help.SetTips128[i].MatchName.ToArray())}"); 
                    //SetBtnEnabled(settingNo / 4 + settingNo % 4 +1, true);
                }
                else
                {
                    //SetBtnEnabled(settingNo / 4 + settingNo % 4 +1, false);
                }
                if (!(null == SettingList_Help.SetTips128[i].data || SettingList_Help.SetTips128[i].data.Count() == 0))
                {
                    SetSettingPath(settingNo, SettingList_Help.SetTips128[i].data);
                    if (SettingList_Help.SetTips128[i].Tips.Contains("CVBS N"))
                    {
                        ParaHelp.Bin_Taoshi_Utc.Find(c => c.Note == "CVBS960H50").PValue = $"0x07";
                        ParaHelp.Bin_Taoshi_Utc.Find(c => c.Note == "CVBS NP").PValue = $"0x01";

                    }
                    else if (SettingList_Help.SetTips128[i].Tips.Contains("CVBS P"))
                    {
                        ParaHelp.Bin_Taoshi_Utc.Find(c => c.Note == "CVBS960H60").PValue = $"0x03";
                        ParaHelp.Bin_Taoshi_Utc.Find(c => c.Note == "CVBS NP").PValue = $"0x01";

                    }
                    else {
                        ParaHelp.Bin_Taoshi_Utc.Find(c => c.Note == "CVBS NP").PValue = $"0x00";
                        ParaHelp.Bin_Taoshi_Utc.Find(c => c.Note == SettingList_Help.SetTips128[i].Tips).PValue = $"0x{Convert.ToInt32(SettingList_Help.SetTips128[i].SettingNo).ToString("X2").PadLeft(2, '0')}";

                    }

                }
            }
            //isloadAgain = false;
            if (noFoundFileList.Count > 0)
                DevExpress.XtraEditors.XtraMessageBox.Show($"文件夹中不存在{string.Join("\r\n",noFoundFileList)}", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);

        }

       


        private void SetSettingPath(int num, List<TreeListValue> data)
        {
            ///osd 情况虾  这个功能暂时放着  写osd 在编写此处逻辑
            /// 
            if (num == int.Parse(settingPathahd_1.Tag.ToString()))//ahd
            {
                settingPathahd_1.Properties.DataSource = data; settingPathahd_1.ItemIndex = 0;
            }
            else if (num == int.Parse(settingPathahd_2.Tag.ToString()))
            {
                settingPathahd_2.Properties.DataSource = data; settingPathahd_2.ItemIndex = 0;
            }
            else if (num == int.Parse(settingPathahd_3.Tag.ToString()))
            {
                settingPathahd_3.Properties.DataSource = data; settingPathahd_3.ItemIndex = 0;
            }
            else if (num == int.Parse(settingPathahd_4.Tag.ToString()))
            {
                settingPathahd_4.Properties.DataSource = data; settingPathahd_4.ItemIndex = 0;
            }
            else if (num == int.Parse(settingPathahd_5.Tag.ToString()))
            {
                settingPathahd_5.Properties.DataSource = data; settingPathahd_5.ItemIndex = 0;
            }
            else if (num == int.Parse(settingPathahd_6.Tag.ToString()))
            {
                settingPathahd_6.Properties.DataSource = data; settingPathahd_6.ItemIndex = 0;
            }
            else if (num == int.Parse(settingPathahd_7.Tag.ToString()))
            {
                settingPathahd_7.Properties.DataSource = data; settingPathahd_7.ItemIndex = 0;
            }
            else if (num == int.Parse(settingPathahd_8.Tag.ToString()))
            {
                settingPathahd_8.Properties.DataSource = data; settingPathahd_8.ItemIndex = 0;
            }
            else if (num == int.Parse(settingPathtvi_1.Tag.ToString())) //THD
            {
                settingPathtvi_1.Properties.DataSource = data; settingPathtvi_1.ItemIndex = 0;
            }
            else if (num == int.Parse(settingPathtvi_2.Tag.ToString()))
            {
                settingPathtvi_2.Properties.DataSource = data; settingPathtvi_2.ItemIndex = 0;
            }
            else if (num == int.Parse(settingPathtvi_3.Tag.ToString()))
            {
                settingPathtvi_3.Properties.DataSource = data; settingPathtvi_3.ItemIndex = 0;
            }
            else if (num == int.Parse(settingPathtvi_4.Tag.ToString()))
            {
                settingPathtvi_4.Properties.DataSource = data; settingPathtvi_4.ItemIndex = 0;
            }
            else if (num == int.Parse(settingPathtvi_5.Tag.ToString()))
            {
                settingPathtvi_5.Properties.DataSource = data; settingPathtvi_5.ItemIndex = 0;
            }
            else if (num == int.Parse(settingPathtvi_6.Tag.ToString()))
            {
                settingPathtvi_6.Properties.DataSource = data; settingPathtvi_6.ItemIndex = 0;
            }
            else if (num == int.Parse(settingPathtvi_7.Tag.ToString()))
            {
                settingPathtvi_7.Properties.DataSource = data; settingPathtvi_7.ItemIndex = 0;
            }
            else if (num == int.Parse(settingPathtvi_8.Tag.ToString()))
            {
                settingPathtvi_8.Properties.DataSource = data; settingPathtvi_8.ItemIndex = 0;
            }
            else if (num == int.Parse(settingPathcvi_1.Tag.ToString()))//chd
            {
                settingPathcvi_1.Properties.DataSource = data; settingPathcvi_1.ItemIndex = 0;
            }
            else if (num == int.Parse(settingPathcvi_2.Tag.ToString()))
            {
                settingPathcvi_2.Properties.DataSource = data; settingPathcvi_2.ItemIndex = 0;
            }
            else if (num == int.Parse(settingPathcvi_3.Tag.ToString()))
            {
                settingPathcvi_3.Properties.DataSource = data; settingPathcvi_3.ItemIndex = 0;
            }
            else if (num == int.Parse(settingPathcvi_4.Tag.ToString()))
            {
                settingPathcvi_4.Properties.DataSource = data; settingPathcvi_4.ItemIndex = 0;
            }
            else if (num == int.Parse(settingPathcvi_5.Tag.ToString()))
            {
                settingPathcvi_5.Properties.DataSource = data; settingPathcvi_5.ItemIndex = 0;
            }
            else if (num == int.Parse(settingPathcvi_6.Tag.ToString()))
            {
                settingPathcvi_6.Properties.DataSource = data; settingPathcvi_6.ItemIndex = 0;
            }
            else if (num == int.Parse(settingPathcvi_7.Tag.ToString()))
            {
                settingPathcvi_7.Properties.DataSource = data; settingPathcvi_7.ItemIndex = 0;
            }
            else if (num == int.Parse(settingPathcvi_8.Tag.ToString()))
            {
                settingPathcvi_8.Properties.DataSource = data; settingPathcvi_8.ItemIndex = 0;
            }
            else if (num == int.Parse(settingPathcvbs_1.Tag.ToString()))//cvbs
            {
                settingPathcvbs_1.Properties.DataSource = data; settingPathcvbs_1.ItemIndex = 0;
            }
            else if (num == int.Parse(settingPathcvbs_2.Tag.ToString()))
            {
                settingPathcvbs_2.Properties.DataSource = data; settingPathcvbs_2.ItemIndex = 0;
            }
            else if (num == int.Parse(settingPathcvbs_3.Tag.ToString()))
            {
                settingPathcvbs_3.Properties.DataSource = data; settingPathcvbs_3.ItemIndex = 0;
            }
            else if (num == int.Parse(settingPathcvbs_4.Tag.ToString()))
            {
                settingPathcvbs_4.Properties.DataSource = data; settingPathcvbs_4.ItemIndex = 0;
            }
            else if (num == int.Parse(settingPathcvbs_5.Tag.ToString()))
            {
                settingPathcvbs_5.Properties.DataSource = data; settingPathcvbs_5.ItemIndex = 0;
            }
            else if (num == int.Parse(settingPathcvbs_6.Tag.ToString()))
            {
                settingPathcvbs_6.Properties.DataSource = data; settingPathcvbs_6.ItemIndex = 0;
            }
            else if (num == int.Parse(settingPathcvbs_7.Tag.ToString()))
            {
                settingPathcvbs_7.Properties.DataSource = data; settingPathcvbs_7.ItemIndex = 0;
            }
            else if (num == int.Parse(settingPathcvbs_8.Tag.ToString()))
            {
                settingPathcvbs_8.Properties.DataSource = data; settingPathcvbs_8.ItemIndex = 0;
            }

        }

        /// <summary>
        /// 更新IQ
        /// </summary>
        /// <param name="filepath"></param>
        /// <returns></returns>

        private XChip_Common.MsgString<List<string>> UpdateParameterNewIQ(string filepath)
        {
            XChip_Common.MsgString<List<string>> msg = new MsgString<List<string>>();
            if (!sPortTemp.IsOpen)
            {
                msg.state = MsgSt.Warn;
                msg.msg = $"可用端口未打开！";
                return msg;
            }
            StreamReader sr = new StreamReader(filepath, Encoding.Default);
            List<string> listStr = new List<string>();
            string line;
            while ((line = sr.ReadLine()) != null)
            {
                listStr.Add(line);
            }
            sr.Close();

            //WaitBefore.Start("参数导出", "正在加载中", 60);
            var Pe_patch_dal = new parameter_export_patchManager();
            var patchList = Pe_patch_dal.GetList();

            //全局变量 0xfffd  0xfffe
            string add = "80";//  0xfffd
            string addval = string.Empty; //0xfffe
            string duVal = string.Empty; //读取的值
            //IQ_common
            var commonStart = Array.FindIndex(listStr.ToArray(), t => t.IndexOf("IQ_common", StringComparison.InvariantCultureIgnoreCase) >= 0);
            #region 判断IQ_common的起始索引
            if (commonStart < 0)
            {
                commonStart = Array.FindIndex(listStr.ToArray(), t => t.IndexOf("AE sensor", StringComparison.InvariantCultureIgnoreCase) >= 0);
                if (commonStart < 0)
                {
                    commonStart = Array.FindIndex(listStr.ToArray(), t => t.IndexOf("Step 10", StringComparison.InvariantCultureIgnoreCase) >= 0);
                }
            }
            #endregion
            //IQ_oneself
            var commonEnd = Array.FindIndex(listStr.ToArray(), t => t.IndexOf("IQ_oneself", StringComparison.InvariantCultureIgnoreCase) >= 0);
            #region 判断setp2的起始索引
            if (commonEnd < 0)
            {
                commonEnd = Array.FindIndex(listStr.ToArray(), t => t.IndexOf("avg_size", StringComparison.InvariantCultureIgnoreCase) >= 0);

            }
            #endregion
            if (commonStart == -1 || commonEnd == -1)
            {
                msg.state = MsgSt.Lose;
                msg.msg = $"无法找到指定更新位置，请先设置";
                return msg;
            }
            WaitBefore.Start("参数导出", "正在加载中", 60);
            SerialSend.isDebug = false;
            for (int i = commonStart; i < commonEnd; i++)
            {
                string[] col = listStr[i].Replace('，', ',').Split(',');
                if (col.Count() > 2)
                {
                    string colFirst = col.First().Trim().ToLower();
                    //过滤关键字
                    if (colFirst == "0xffff" || colFirst == "0xfff3" || colFirst == "0xfff6" || colFirst == "0xfff7" || colFirst == "0xfff8" || colFirst == "0xfff9" || colFirst == "0xfffa" || colFirst == "0xfff0" || colFirst == "0xfff1")
                    {
                        continue;
                    }
                    else if (colFirst == "0xfffd")
                    {
                        add = col[1].Replace("0x", "");
                    }
                    else if (colFirst == "0xfffe")
                    {
                        addval = col[1].Replace("0x", "");
                    }
                    else if (colFirst.Contains("0x") && !colFirst.Contains("//"))
                    {
                        try
                        {
                            string sonVal = colFirst.Replace("0x", "").Replace(" ", "");
                            duVal = (add + addval + sonVal.PadLeft(4, '0')).Replace("0x", "").Replace(" ", "").ToLower();
                            if (duVal.Length != 8 || duVal == "80300000" || duVal == "80300001" || duVal == "80300002" || duVal == "80300003" || duVal == "80300004"
                                     || duVal == "8014062c")
                                continue;

                            long tempVal = -1;

                            if (patchList.Count != 0 && patchList.Select(c => c.ReadAddr).Contains(duVal))
                            {
                                var patchModel = patchList.First(c => c.ReadAddr.Contains(duVal));
                                if (string.IsNullOrEmpty(patchModel.ConditionAddr) && string.IsNullOrEmpty(patchModel.RelationAddr) && !string.IsNullOrEmpty(patchModel.Val))
                                {
                                    tempVal = Convert.ToUInt32(patchModel.Val, 16);
                                }
                                else if (!string.IsNullOrEmpty(patchModel.ConditionAddr) && SerialSend.ReadRegister(Convert.ToUInt32(patchModel.ConditionAddr, 16), sPortTemp) == 0)
                                {
                                    tempVal = SerialSend.ReadRegister(Convert.ToUInt32(patchModel.ReadAddr, 16), sPortTemp);
                                }
                                else if (string.IsNullOrEmpty(patchModel.RelationAddr) && string.IsNullOrEmpty(patchModel.ConditionAddr) && !string.IsNullOrEmpty(patchModel.Bit))
                                {
                                    tempVal = Convert.ToUInt32(patchModel.Bit, 16);
                                }
                                else
                                {
                                    if (!string.IsNullOrEmpty(patchModel.Bit) && patchModel.Bit.Contains("&0x7f"))
                                    {
                                        tempVal = SerialSend.ReadRegister(Convert.ToUInt32(patchModel.RelationAddr, 16), sPortTemp) & 0x7f;
                                    }
                                    else
                                    {
                                        tempVal = SerialSend.ReadRegister(Convert.ToUInt32(patchModel.RelationAddr, 16), sPortTemp);
                                    }

                                }
                            }
                            else
                            {
                                tempVal = SerialSend.ReadRegister(Convert.ToUInt32(duVal, 16), sPortTemp);
                                switch (duVal)
                                {
                                    case "80500021":
                                        tempVal |= 0x08;
                                        break;
                                    case "8050001c":
                                        tempVal |= 0x01;
                                        break;
                                    case "80200002":
                                        tempVal &= 0x7f;
                                        break;
                                    case "8020002c":
                                        tempVal |= 0x01;
                                        break;
                                    case "80500200":
                                        tempVal &= 0x0f;
                                        break;
                                    default:
                                        break;
                                }
                                //col[1] = col[1].Contains(" ") ? " 0x" + tempVal.ToString("x2") : "0x" + tempVal.ToString("x2");

                            }
                            string oldVal = col[1].Replace("0x", "").Replace(" ", "");
                            col[1] = col[1].Replace(oldVal, tempVal.ToString("x2"));
                            listStr[i] = string.Join(",", col);
                        }
                        catch (Exception ex)
                        {
                            WaitBefore.Close();
                            DevExpress.XtraEditors.XtraMessageBox.Show(ex.ToString());
                            throw;
                        }
                    }
                }
            }
            SerialSend.isDebug = true;
            WaitBefore.Close();
            msg.state = MsgSt.Success;
            msg.data = listStr;
            return msg;
        }
        /// <summary>
        /// 传入setting路径，更新参数
        /// </summary>
        /// <returns></returns>
        private XChip_Common.MsgString<List<string>> UpdateParameter(string filepath, bool stIndex = true)
        {
            XChip_Common.MsgString<List<string>> msg = new MsgString<List<string>>();
            if (!sPortTemp.IsOpen)
            {
                msg.state = MsgSt.Warn;
                msg.msg = $"可用端口未打开！";
                return msg;
            }
            var Pe_patch_dal = new parameter_export_patchManager();
            var patchList = Pe_patch_dal.GetList();
            StreamReader sr = new StreamReader(filepath, Encoding.Default);
            List<string> listStr = new List<string>();
            string line;
            while ((line = sr.ReadLine()) != null)
            {
                listStr.Add(line);
            }
            sr.Close();
            //全局变量 0xfffd  0xfffe
            string add = "80";//  0xfffd
            string addval = string.Empty; //0xfffe
            string duVal = string.Empty; //读取的值
            int step2Start = -1;
            //onself iq 也采用这种方式进行更新
            if (stIndex)
            {
                step2Start = Array.FindIndex(listStr.ToArray(), t => t.IndexOf("Step 2 reconfig system", StringComparison.InvariantCultureIgnoreCase) >= 0);
                #region 判断setp2的起始索引
                if (step2Start < 0)
                {
                    step2Start = Array.FindIndex(listStr.ToArray(), t => t.IndexOf("Step 2", StringComparison.InvariantCultureIgnoreCase) >= 0);
                    if (step2Start < 0)
                    {
                        step2Start = Array.FindIndex(listStr.ToArray(), t => t.IndexOf("Step2", StringComparison.InvariantCultureIgnoreCase) >= 0);
                    }
                }
                #endregion
            }
            else
            {
                step2Start = Array.FindIndex(listStr.ToArray(), t => t.IndexOf("Step 2", StringComparison.InvariantCultureIgnoreCase) >= 0);
                #region 判断setp2的起始索引
                if (step2Start < 0)
                {
                    step2Start = Array.FindIndex(listStr.ToArray(), t => t.IndexOf("Step 3", StringComparison.InvariantCultureIgnoreCase) >= 0);
                    if (step2Start < 0)
                    {
                        step2Start = Array.FindIndex(listStr.ToArray(), t => t.IndexOf("Step 4", StringComparison.InvariantCultureIgnoreCase) >= 0);
                    }
                }
                #endregion
            }

            #region 判断sensor的起始索引
            var sensorStart = Array.FindIndex(listStr.ToArray(), t => t.IndexOf("0xfff8", StringComparison.InvariantCultureIgnoreCase) >= 0);
            var sensorEnd = -1;
            if (sensorStart != -1)
            {
                sensorEnd = Array.FindIndex(listStr.ToArray(), sensorStart + 1, t => t.IndexOf("0xfff8", StringComparison.InvariantCultureIgnoreCase) >= 0) + 1;
            }
            else
            {
                sensorStart = Array.FindIndex(listStr.ToArray(), t => t.IndexOf("0xfff0", StringComparison.InvariantCultureIgnoreCase) >= 0);
                if (sensorStart != -1)
                {
                    sensorEnd = Array.FindIndex(listStr.ToArray(), sensorStart + 1, t => t.IndexOf("0xfff0", StringComparison.InvariantCultureIgnoreCase) >= 0) + 1;
                }
            }
            #endregion
            int patchStart = listStr.FindIndex(c => c.ToLower().Contains("patch_start"));
            int patchEnd = listStr.FindIndex(c => c.ToLower().Contains("patch_end"));
            int disableUpdateStart = listStr.FindIndex(c => c.ToLower().Contains("disable_update_start"));
            int disableUpdateEnd = listStr.FindIndex(c => c.ToLower().Contains("disable_update_end"));
            WaitBefore.Start("参数导出", "正在加载中", 60);
            SerialSend.isDebug = false;
            #region 更新逻辑
            for (int i = (step2Start < 0 ? 0 : step2Start); i < listStr.Count(); i++)
            {
                if (i == 3825)
                {

                }
                //if ((i >= startIndex && i <= endIndex) || (i >= sensorStart && i <= sensorEnd))
                if (listStr[i].ToLower().Contains("disable_update_start"))
                {
                    while (!listStr[i++].ToLower().Contains("disable_update_end"))
                    {
                        string[] col_re = listStr[i].Replace('，', ',').Split(',');
                        if (col_re.Count() > 2)
                        {
                            string colFirst = col_re.First().Trim().ToLower();
                            //过滤关键字
                            if (colFirst == "0xffff" || colFirst == "0xfff3" || colFirst == "0xfff6" || colFirst == "0xfff7" || colFirst == "0xfff8" || colFirst == "0xfff9" || colFirst == "0xfffa" || colFirst == "0xfff0" || colFirst == "0xfff1")
                            {
                                continue;
                            }
                            else if (colFirst == "0xfffd")
                            {
                                add = col_re[1].Replace("0x", "");
                            }
                            else if (colFirst == "0xfffe")
                            {
                                addval = col_re[1].Replace("0x", "");
                            }
                        }
                    };
                }
                if ((i >= sensorStart && i <= sensorEnd) || (i >= patchStart && i <= patchEnd))//跳过sensor部分和patch部分
                {
                    continue;
                }
                string[] col = listStr[i].Replace('，', ',').Split(',');
                if (col.Count() > 2)
                {
                    string colFirst = col.First().Trim().ToLower();
                    //过滤关键字
                    if (colFirst == "0xffff" || colFirst == "0xfff3" || colFirst == "0xfff6" || colFirst == "0xfff7" || colFirst == "0xfff8" || colFirst == "0xfff9" || colFirst == "0xfffa" || colFirst == "0xfff0" || colFirst == "0xfff1")
                    {
                        continue;
                    }
                    else if (colFirst == "0xfffd")
                    {
                        add = col[1].Replace("0x", "");
                    }
                    else if (colFirst == "0xfffe")
                    {
                        addval = col[1].Replace("0x", "");
                    }
                    else if (colFirst.Contains("0x") && !colFirst.Contains("//"))
                    {
                        try
                        {
                            string sonVal = colFirst.Replace("0x", "").Replace(" ", "");
                            duVal = (add + addval + sonVal.PadLeft(4, '0')).Replace("0x", "").Replace(" ", "").ToLower();
                            //暂时不知道什么原因 过滤了
                            //if (duVal.Length != 8 || duVal == "80300000" || duVal == "80300001" || duVal == "80300002" || duVal == "80300003" || duVal == "80300004"
                            //     || duVal == "8014062c")
                            //    continue;

                            long tempVal = -1;  //加入iq 特殊处理代码

                            if (patchList.Count != 0 && patchList.Select(c => c.ReadAddr).Contains(duVal))
                            {
                                var patchModel = patchList.First(c => c.ReadAddr.Contains(duVal));


                                if (string.IsNullOrEmpty(patchModel.ConditionAddr) && string.IsNullOrEmpty(patchModel.RelationAddr) && !string.IsNullOrEmpty(patchModel.Val))
                                {
                                    tempVal = Convert.ToUInt32(patchModel.Val, 16);
                                }
                                else if (!string.IsNullOrEmpty(patchModel.ConditionAddr) && SerialSend.ReadRegister(Convert.ToUInt32(patchModel.ConditionAddr, 16), sPortTemp) == 0)
                                {
                                    tempVal = SerialSend.ReadRegister(Convert.ToUInt32(patchModel.ReadAddr, 16), sPortTemp);
                                }
                                else if (string.IsNullOrEmpty(patchModel.RelationAddr) && string.IsNullOrEmpty(patchModel.ConditionAddr) && !string.IsNullOrEmpty(patchModel.Bit))
                                {
                                    tempVal = Convert.ToUInt32(patchModel.Bit, 16);
                                }
                                else
                                {
                                    if (!string.IsNullOrEmpty(patchModel.Bit) && patchModel.Bit.Contains("&0x7f"))
                                    {
                                        tempVal = SerialSend.ReadRegister(Convert.ToUInt32(patchModel.RelationAddr, 16), sPortTemp) & 0x7f;
                                    }
                                    else
                                    {
                                        tempVal = SerialSend.ReadRegister(Convert.ToUInt32(patchModel.RelationAddr, 16), sPortTemp);
                                    }

                                }
                            }
                            else
                            {
                                tempVal = SerialSend.ReadRegister(Convert.ToUInt32(duVal, 16), sPortTemp);
                                switch (duVal)
                                {
                                    case "80500021":
                                        tempVal |= 0x08;
                                        break;
                                    case "8050001c":
                                        tempVal |= 0x01;
                                        break;
                                    case "80200002":
                                        tempVal &= 0x7f;
                                        break;
                                    case "8020002c":
                                        tempVal |= 0x01;
                                        break;
                                    case "80500200":
                                        tempVal &= 0x0f;
                                        break;
                                    default:
                                        break;
                                }
                            }
                            string oldVal = col[1].Replace("0x", "").Replace(" ", "");
                            col[1] = col[1].Replace(oldVal, tempVal.ToString("x2"));
                            listStr[i] = string.Join(",", col);
                        }
                        catch (Exception ex)
                        {
                            WaitBefore.Close();
                            DevExpress.XtraEditors.XtraMessageBox.Show(ex.Message);
                            throw;
                        }
                    }
                    else
                    {
                        continue;
                    }
                }
                else
                {
                    continue;
                }
            }
            #endregion
            SerialSend.isDebug = true;
            WaitBefore.Close();
            msg.state = MsgSt.Success;
            msg.data = listStr;
            return msg;
        }



        private void IQ_ComBtn_Click(object sender, EventArgs e)
        {
            if (commonTxt.ItemIndex == -1)//common必须选择，否则无法计算长度
            {
                DevExpress.XtraEditors.XtraMessageBox.Show($"未选择xchip_IQ_common_setting", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            //文件名称 和文件路径 
            var path = commonTxt.EditValue.ToString();
            string tempPath = string.Empty;
            if (System.IO.Path.GetDirectoryName(path).Contains("SettingTemp"))
            {
                tempPath = System.IO.Path.GetDirectoryName(path) + "\\";
            }
            else
            {
                tempPath = System.IO.Path.GetDirectoryName(path) + "\\SettingTemp\\";
            }

            string tempName = string.Empty;
            if (Path.GetFileNameWithoutExtension(path).Contains("com"))
            {
                var t = Path.GetFileNameWithoutExtension(path);
                var end = t.IndexOf("_com");
                tempName = t.Substring(0, end) + "_common_" + DateTime.Now.ToString("MMddHHmmss");
            }
            else if (Path.GetFileNameWithoutExtension(path).Contains("iq"))
            {
                var t = Path.GetFileNameWithoutExtension(path);
                var end = t.IndexOf("_iq");
                tempName = t.Substring(0, end) + "_common_" + DateTime.Now.ToString("MMddHHmmss");
            }
            else if (Path.GetFileNameWithoutExtension(path).Contains("all"))
            {
                var t = Path.GetFileNameWithoutExtension(path);
                var end = t.IndexOf("_all");
                tempName = t.Substring(0, end) + "_common_" + DateTime.Now.ToString("MMddHHmmss");
            }
            else
            {
                tempName = Path.GetFileNameWithoutExtension(path) + "_common_" + DateTime.Now.ToString("MMddHHmmss");
            }
            //确定目录是否存在
            if (!Directory.Exists(tempPath))
            {
                //创建它不存在的目录
                Directory.CreateDirectory(tempPath);
            }

            var pSaveFilePath = $"{tempPath}{tempName}{Path.GetExtension(path)}";
            if (!File.Exists(pSaveFilePath))//必须判断要复制的文件是否存在
            {
                File.Copy(path, pSaveFilePath, true);//三个参数分别是源文件路径，存储路径，若存储路径有相同文件是否替换
            }

            //更新IQ
            var msg = UpdateParameter(pSaveFilePath, false);
            if (msg.state == MsgSt.Success)
            {
                if (File.Exists(pSaveFilePath))
                {
                    File.Delete(pSaveFilePath);
                }
                File.WriteAllLines(pSaveFilePath, msg.data, Encoding.Default);
                commonList.Add(new TreeListValue { ValueMember = pSaveFilePath, DisplayMember = Path.GetFileName(pSaveFilePath) });
                commonTxt.Properties.DataSource = commonList;
                commonTxt.ItemIndex = commonList.Count - 1;
            }
            else
            {
                XtraMessageBox.Show($"更新错误：{msg.msg}", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        #region ahd
        private void osahdbtn1_Click(object sender, EventArgs e)
        {
            var btn = sender as SimpleButton;
            string path = string.Empty;
            switch (btn.Tag.ToString())
            {
                case "1":
                    path = settingPathahd_1.EditValue.ToString();
                    break;
                case "2":
                    path = settingPathahd_2.EditValue.ToString();
                    break;
                case "3":
                    path = settingPathahd_3.EditValue.ToString();
                    break;
                case "4":
                    path = settingPathahd_4.EditValue.ToString();
                    break;
                case "5":
                    path = settingPathahd_5.EditValue.ToString();
                    break;
                case "6":
                    path = settingPathahd_6.EditValue.ToString();
                    break;
                case "7":
                    path = settingPathahd_7.EditValue.ToString();
                    break;
                case "8":
                    path = settingPathahd_8.EditValue.ToString();
                    break;
                default:
                    path = string.Empty;
                    break;
            }
            if (string.IsNullOrEmpty(path) || path.Contains("请选择"))
            {
                DevExpress.XtraEditors.XtraMessageBox.Show($"1080配置 OS 文件路径未选择！", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            string tempPath = string.Empty;
            if (System.IO.Path.GetDirectoryName(path).Contains("SettingTemp"))
            {
                tempPath = System.IO.Path.GetDirectoryName(path) + "\\";
            }
            else
            {
                tempPath = System.IO.Path.GetDirectoryName(path) + "\\SettingTemp\\";
            }

            string tempName = string.Empty;
            if (Path.GetFileNameWithoutExtension(path).Contains("all"))
            {
                var t = Path.GetFileNameWithoutExtension(path);
                var end = t.IndexOf("_all");
                tempName = t.Substring(0, end) + "_all_" + DateTime.Now.ToString("MMddHHmmss");
            }
            else if (Path.GetFileNameWithoutExtension(path).Contains("iq"))
            {
                var t = Path.GetFileNameWithoutExtension(path);
                var end = t.IndexOf("_iq");
                tempName = t.Substring(0, end) + "_all_" + DateTime.Now.ToString("MMddHHmmss");
            }
            else
            {
                tempName = Path.GetFileNameWithoutExtension(path) + "_all_" + DateTime.Now.ToString("MMddHHmmss");
            }


            //确定目录是否存在
            if (!Directory.Exists(tempPath))
            {
                //创建它不存在的目录
                Directory.CreateDirectory(tempPath);
            }

            var pSaveFilePath = $"{tempPath}{tempName}{Path.GetExtension(path)}";
            if (!File.Exists(pSaveFilePath))//必须判断要复制的文件是否存在
            {
                File.Copy(path, pSaveFilePath, true);//三个参数分别是源文件路径，存储路径，若存储路径有相同文件是否替换
            }

            //更新OS
            var msg = UpdateParameter(pSaveFilePath);
            if (msg.state == MsgSt.Success)
            {
                if (File.Exists(pSaveFilePath))
                {
                    File.Delete(pSaveFilePath);
                }
                File.WriteAllLines(pSaveFilePath, msg.data, Encoding.Default);
                switch (btn.Tag.ToString())
                {
                    case "1":
                        SettingList_Help.SetTips128[0].data.Add(new TreeListValue() { ValueMember = pSaveFilePath, DisplayMember = Path.GetFileName(pSaveFilePath)  });
                        settingPathahd_1.Properties.DataSource = SettingList_Help.SetTips128[0].data;
                        settingPathahd_1.ItemIndex = SettingList_Help.SetTips128[0].data.Count() - 1;
                        break;
                    case "2":
                        SettingList_Help.SetTips128[1].data.Add(new TreeListValue() { ValueMember = pSaveFilePath, DisplayMember = Path.GetFileName(pSaveFilePath)  });
                        settingPathahd_2.Properties.DataSource = SettingList_Help.SetTips128[1].data;
                        settingPathahd_2.ItemIndex = SettingList_Help.SetTips128[1].data.Count() - 1;
                        break;
                    case "3":
                        SettingList_Help.SetTips128[2].data.Add(new TreeListValue() { ValueMember = pSaveFilePath, DisplayMember = Path.GetFileName(pSaveFilePath)  });
                        settingPathahd_3.Properties.DataSource = SettingList_Help.SetTips128[2].data;
                        settingPathahd_3.ItemIndex = SettingList_Help.SetTips128[2].data.Count() - 1;
                        break;
                    case "4":
                        SettingList_Help.SetTips128[3].data.Add(new TreeListValue() { ValueMember = pSaveFilePath, DisplayMember = Path.GetFileName(pSaveFilePath)  });
                        settingPathahd_4.Properties.DataSource = SettingList_Help.SetTips128[3].data;
                        settingPathahd_4.ItemIndex = SettingList_Help.SetTips128[3].data.Count() - 1;
                        break;
                    case "5":
                        SettingList_Help.SetTips128[4].data.Add(new TreeListValue() { ValueMember = pSaveFilePath, DisplayMember = Path.GetFileName(pSaveFilePath)  });
                        settingPathahd_5.Properties.DataSource = SettingList_Help.SetTips128[4].data;
                        settingPathahd_5.ItemIndex = SettingList_Help.SetTips128[4].data.Count() - 1;
                        break;
                    case "6":
                        SettingList_Help.SetTips128[5].data.Add(new TreeListValue() { ValueMember = pSaveFilePath, DisplayMember = Path.GetFileName(pSaveFilePath)  });
                        settingPathahd_6.Properties.DataSource = SettingList_Help.SetTips128[5].data;
                        settingPathahd_6.ItemIndex = SettingList_Help.SetTips128[5].data.Count() - 1;
                        break;
                    case "7":
                        SettingList_Help.SetTips128[6].data.Add(new TreeListValue() { ValueMember = pSaveFilePath, DisplayMember = Path.GetFileName(pSaveFilePath)  });
                        settingPathahd_7.Properties.DataSource = SettingList_Help.SetTips128[6].data;
                        settingPathahd_7.ItemIndex = SettingList_Help.SetTips128[6].data.Count() - 1;
                        break;
                    case "8":
                        SettingList_Help.SetTips128[7].data.Add(new TreeListValue() { ValueMember = pSaveFilePath, DisplayMember = Path.GetFileName(pSaveFilePath)  });
                        settingPathahd_8.Properties.DataSource = SettingList_Help.SetTips128[7].data;
                        settingPathahd_8.ItemIndex = SettingList_Help.SetTips128[7].data.Count() - 1;
                        break;
                    default:
                        break;
                }
            }
            else
            {
                XtraMessageBox.Show($"更新错误：{msg.msg}", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void iqahdbtn1_Click(object sender, EventArgs e)
        {
            var btn = sender as SimpleButton;
            string path = string.Empty;
            switch (btn.Tag.ToString())
            {
                case "1":
                    path = settingPathahd_1.EditValue.ToString();
                    break;
                case "2":
                    path = settingPathahd_2.EditValue.ToString();
                    break;
                case "3":
                    path = settingPathahd_3.EditValue.ToString();
                    break;
                case "4":
                    path = settingPathahd_4.EditValue.ToString();
                    break;
                case "5":
                    path = settingPathahd_5.EditValue.ToString();
                    break;
                case "6":
                    path = settingPathahd_6.EditValue.ToString();
                    break;
                case "7":
                    path = settingPathahd_7.EditValue.ToString();
                    break;
                case "8":
                    path = settingPathahd_8.EditValue.ToString();
                    break;
                default:
                    path = string.Empty;
                    break;
            }

            if (string.IsNullOrEmpty(path) || path.Contains("请选择"))
            {
                DevExpress.XtraEditors.XtraMessageBox.Show($"1080配置 IQ 文件路径未选择！", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            string tempPath = string.Empty;
            if (System.IO.Path.GetDirectoryName(path).Contains("SettingTemp"))
            {
                tempPath = System.IO.Path.GetDirectoryName(path) + "\\";
            }
            else
            {
                tempPath = System.IO.Path.GetDirectoryName(path) + "\\SettingTemp\\";
            }
            string tempName = string.Empty;
            if (Path.GetFileNameWithoutExtension(path).Contains("iq"))
            {
                var t = Path.GetFileNameWithoutExtension(path);
                var end = t.IndexOf("_iq");
                tempName = t.Substring(0, end) + "_iq_" + DateTime.Now.ToString("MMddHHmmss");
            }
            else if (Path.GetFileNameWithoutExtension(path).Contains("all"))
            {
                var t = Path.GetFileNameWithoutExtension(path);
                var end = t.IndexOf("_all");
                tempName = t.Substring(0, end) + "_iq_" + DateTime.Now.ToString("MMddHHmmss");
            }
            else
            {
                tempName = Path.GetFileNameWithoutExtension(path) + "_iq_" + DateTime.Now.ToString("MMddHHmmss");
            }
            //确定目录是否存在
            if (!Directory.Exists(tempPath))
            {
                //创建它不存在的目录
                Directory.CreateDirectory(tempPath);
            }

            var pSaveFilePath = $"{tempPath}{tempName}{Path.GetExtension(path)}";
            if (!File.Exists(pSaveFilePath))//必须判断要复制的文件是否存在
            {
                File.Copy(path, pSaveFilePath, true);//三个参数分别是源文件路径，存储路径，若存储路径有相同文件是否替换
            }
            //更新IQ
            var msg = UpdateParameterNewIQ(pSaveFilePath);
            if (msg.state == MsgSt.Success)
            {
                if (File.Exists(pSaveFilePath))
                {
                    File.Delete(pSaveFilePath);
                }
                File.WriteAllLines(pSaveFilePath, msg.data, Encoding.Default);
                switch (btn.Tag.ToString())
                {
                    case "1":
                        SettingList_Help.SetTips128[0].data.Add(new TreeListValue() { ValueMember = pSaveFilePath, DisplayMember = Path.GetFileName(pSaveFilePath)  });
                        settingPathahd_1.Properties.DataSource = SettingList_Help.SetTips128[0].data;
                        settingPathahd_1.ItemIndex = SettingList_Help.SetTips128[0].data.Count() - 1;
                        break;
                    case "2":
                        SettingList_Help.SetTips128[1].data.Add(new TreeListValue() { ValueMember = pSaveFilePath, DisplayMember = Path.GetFileName(pSaveFilePath)  });
                        settingPathahd_2.Properties.DataSource = SettingList_Help.SetTips128[1].data;
                        settingPathahd_2.ItemIndex = SettingList_Help.SetTips128[1].data.Count() - 1;
                        break;
                    case "3":
                        SettingList_Help.SetTips128[2].data.Add(new TreeListValue() { ValueMember = pSaveFilePath, DisplayMember = Path.GetFileName(pSaveFilePath)  });
                        settingPathahd_3.Properties.DataSource = SettingList_Help.SetTips128[2].data;
                        settingPathahd_3.ItemIndex = SettingList_Help.SetTips128[2].data.Count() - 1;
                        break;
                    case "4":
                        SettingList_Help.SetTips128[3].data.Add(new TreeListValue() { ValueMember = pSaveFilePath, DisplayMember = Path.GetFileName(pSaveFilePath)  });
                        settingPathahd_4.Properties.DataSource = SettingList_Help.SetTips128[3].data;
                        settingPathahd_4.ItemIndex = SettingList_Help.SetTips128[3].data.Count() - 1;
                        break;
                    case "5":
                        SettingList_Help.SetTips128[4].data.Add(new TreeListValue() { ValueMember = pSaveFilePath, DisplayMember = Path.GetFileName(pSaveFilePath)  });
                        settingPathahd_5.Properties.DataSource = SettingList_Help.SetTips128[4].data;
                        settingPathahd_5.ItemIndex = SettingList_Help.SetTips128[4].data.Count() - 1;
                        break;
                    case "6":
                        SettingList_Help.SetTips128[5].data.Add(new TreeListValue() { ValueMember = pSaveFilePath, DisplayMember = Path.GetFileName(pSaveFilePath)  });
                        settingPathahd_6.Properties.DataSource = SettingList_Help.SetTips128[5].data;
                        settingPathahd_6.ItemIndex = SettingList_Help.SetTips128[5].data.Count() - 1;
                        break;
                    case "7":
                        SettingList_Help.SetTips128[6].data.Add(new TreeListValue() { ValueMember = pSaveFilePath, DisplayMember = Path.GetFileName(pSaveFilePath)  });
                        settingPathahd_7.Properties.DataSource = SettingList_Help.SetTips128[6].data;
                        settingPathahd_7.ItemIndex = SettingList_Help.SetTips128[6].data.Count() - 1;
                        break;
                    case "8":
                        SettingList_Help.SetTips128[7].data.Add(new TreeListValue() { ValueMember = pSaveFilePath, DisplayMember = Path.GetFileName(pSaveFilePath)  });
                        settingPathahd_8.Properties.DataSource = SettingList_Help.SetTips128[7].data;
                        settingPathahd_8.ItemIndex = SettingList_Help.SetTips128[7].data.Count() - 1;
                        break;
                    default:
                        break;
                }
            }
            else
            {
                XtraMessageBox.Show($"更新错误：{msg.msg}", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }

        #endregion
        #region tvi

        private void ostvibtn1_Click(object sender, EventArgs e)
        {
            var btn = sender as SimpleButton;
            string path = string.Empty;
            switch (btn.Tag.ToString())
            {
                case "1":
                    path = settingPathtvi_1.EditValue.ToString();
                    break;
                case "2":
                    path = settingPathtvi_2.EditValue.ToString();
                    break;
                case "3":
                    path = settingPathtvi_3.EditValue.ToString();
                    break;
                case "4":
                    path = settingPathtvi_4.EditValue.ToString();
                    break;
                case "5":
                    path = settingPathtvi_5.EditValue.ToString();
                    break;
                case "6":
                    path = settingPathtvi_6.EditValue.ToString();
                    break;
                case "7":
                    path = settingPathtvi_7.EditValue.ToString();
                    break;
                case "8":
                    path = settingPathtvi_8.EditValue.ToString();
                    break;
                default:
                    path = string.Empty;
                    break;
            }
            if (string.IsNullOrEmpty(path) || path.Contains("请选择"))
            {
                DevExpress.XtraEditors.XtraMessageBox.Show($"1080配置 OS 文件路径未选择！", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            string tempPath = string.Empty;
            if (System.IO.Path.GetDirectoryName(path).Contains("SettingTemp"))
            {
                tempPath = System.IO.Path.GetDirectoryName(path) + "\\";
            }
            else
            {
                tempPath = System.IO.Path.GetDirectoryName(path) + "\\SettingTemp\\";
            }

            string tempName = string.Empty;
            if (Path.GetFileNameWithoutExtension(path).Contains("all"))
            {
                var t = Path.GetFileNameWithoutExtension(path);
                var end = t.IndexOf("_all");
                tempName = t.Substring(0, end) + "_all_" + DateTime.Now.ToString("MMddHHmmss");
            }
            else if (Path.GetFileNameWithoutExtension(path).Contains("iq"))
            {
                var t = Path.GetFileNameWithoutExtension(path);
                var end = t.IndexOf("_iq");
                tempName = t.Substring(0, end) + "_all_" + DateTime.Now.ToString("MMddHHmmss");
            }
            else
            {
                tempName = Path.GetFileNameWithoutExtension(path) + "_all_" + DateTime.Now.ToString("MMddHHmmss");
            }


            //确定目录是否存在
            if (!Directory.Exists(tempPath))
            {
                //创建它不存在的目录
                Directory.CreateDirectory(tempPath);
            }

            var pSaveFilePath = $"{tempPath}{tempName}{Path.GetExtension(path)}";
            if (!File.Exists(pSaveFilePath))//必须判断要复制的文件是否存在
            {
                File.Copy(path, pSaveFilePath, true);//三个参数分别是源文件路径，存储路径，若存储路径有相同文件是否替换
            }

            //更新OS
            var msg = UpdateParameter(pSaveFilePath);
            if (msg.state == MsgSt.Success)
            {
                if (File.Exists(pSaveFilePath))
                {
                    File.Delete(pSaveFilePath);
                }
                File.WriteAllLines(pSaveFilePath, msg.data, Encoding.Default);
                switch (btn.Tag.ToString())
                {
                    case "1":
                        SettingList_Help.SetTips128[8].data.Add(new TreeListValue() { ValueMember = pSaveFilePath, DisplayMember = Path.GetFileName(pSaveFilePath)  });
                        settingPathtvi_1.Properties.DataSource = SettingList_Help.SetTips128[8].data;
                        settingPathtvi_1.ItemIndex = SettingList_Help.SetTips128[8].data.Count() - 1;
                        break;
                    case "2":
                        SettingList_Help.SetTips128[9].data.Add(new TreeListValue() { ValueMember = pSaveFilePath, DisplayMember = Path.GetFileName(pSaveFilePath)  });
                        settingPathtvi_2.Properties.DataSource = SettingList_Help.SetTips128[9].data;
                        settingPathtvi_2.ItemIndex = SettingList_Help.SetTips128[9].data.Count() - 1;
                        break;
                    case "3":
                        SettingList_Help.SetTips128[10].data.Add(new TreeListValue() { ValueMember = pSaveFilePath, DisplayMember = Path.GetFileName(pSaveFilePath)  });
                        settingPathtvi_3.Properties.DataSource = SettingList_Help.SetTips128[10].data;
                        settingPathtvi_3.ItemIndex = SettingList_Help.SetTips128[10].data.Count() - 1;
                        break;
                    case "4":
                        SettingList_Help.SetTips128[11].data.Add(new TreeListValue() { ValueMember = pSaveFilePath, DisplayMember = Path.GetFileName(pSaveFilePath)  });
                        settingPathtvi_4.Properties.DataSource = SettingList_Help.SetTips128[11].data;
                        settingPathtvi_4.ItemIndex = SettingList_Help.SetTips128[11].data.Count() - 1;
                        break;
                    case "5":
                        SettingList_Help.SetTips128[12].data.Add(new TreeListValue() { ValueMember = pSaveFilePath, DisplayMember = Path.GetFileName(pSaveFilePath)  });
                        settingPathtvi_5.Properties.DataSource = SettingList_Help.SetTips128[12].data;
                        settingPathtvi_5.ItemIndex = SettingList_Help.SetTips128[12].data.Count() - 1;
                        break;
                    case "6":
                        SettingList_Help.SetTips128[13].data.Add(new TreeListValue() { ValueMember = pSaveFilePath, DisplayMember = Path.GetFileName(pSaveFilePath)  });
                        settingPathtvi_6.Properties.DataSource = SettingList_Help.SetTips128[13].data;
                        settingPathtvi_6.ItemIndex = SettingList_Help.SetTips128[13].data.Count() - 1;
                        break;
                    case "7":
                        SettingList_Help.SetTips128[14].data.Add(new TreeListValue() { ValueMember = pSaveFilePath, DisplayMember = Path.GetFileName(pSaveFilePath)  });
                        settingPathtvi_7.Properties.DataSource = SettingList_Help.SetTips128[14].data;
                        settingPathtvi_7.ItemIndex = SettingList_Help.SetTips128[14].data.Count() - 1;
                        break;
                    case "8":
                        SettingList_Help.SetTips128[15].data.Add(new TreeListValue() { ValueMember = pSaveFilePath, DisplayMember = Path.GetFileName(pSaveFilePath)  });
                        settingPathtvi_8.Properties.DataSource = SettingList_Help.SetTips128[15].data;
                        settingPathtvi_8.ItemIndex = SettingList_Help.SetTips128[15].data.Count() - 1;
                        break;
                    default:
                        break;
                }
            }
            else
            {
                XtraMessageBox.Show($"更新错误：{msg.msg}", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }

        private void iqtvibtn1_Click(object sender, EventArgs e)
        {
            var btn = sender as SimpleButton;
            string path = string.Empty;
            switch (btn.Tag.ToString())
            {
                case "1":
                    path = settingPathtvi_1.EditValue.ToString();
                    break;
                case "2":
                    path = settingPathtvi_2.EditValue.ToString();
                    break;
                case "3":
                    path = settingPathtvi_3.EditValue.ToString();
                    break;
                case "4":
                    path = settingPathtvi_4.EditValue.ToString();
                    break;
                case "5":
                    path = settingPathtvi_5.EditValue.ToString();
                    break;
                case "6":
                    path = settingPathtvi_6.EditValue.ToString();
                    break;
                case "7":
                    path = settingPathtvi_7.EditValue.ToString();
                    break;
                case "8":
                    path = settingPathtvi_8.EditValue.ToString();
                    break;
                default:
                    path = string.Empty;
                    break;
            }
            if (string.IsNullOrEmpty(path) || path.Contains("请选择"))
            {
                DevExpress.XtraEditors.XtraMessageBox.Show($"1080配置 IQ 文件路径未选择！", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            string tempPath = string.Empty;
            if (System.IO.Path.GetDirectoryName(path).Contains("SettingTemp"))
            {
                tempPath = System.IO.Path.GetDirectoryName(path) + "\\";
            }
            else
            {
                tempPath = System.IO.Path.GetDirectoryName(path) + "\\SettingTemp\\";
            }
            string tempName = string.Empty;
            if (Path.GetFileNameWithoutExtension(path).Contains("iq"))
            {
                var t = Path.GetFileNameWithoutExtension(path);
                var end = t.IndexOf("_iq");
                tempName = t.Substring(0, end) + "_iq_" + DateTime.Now.ToString("MMddHHmmss");
            }
            else if (Path.GetFileNameWithoutExtension(path).Contains("all"))
            {
                var t = Path.GetFileNameWithoutExtension(path);
                var end = t.IndexOf("_all");
                tempName = t.Substring(0, end) + "_iq_" + DateTime.Now.ToString("MMddHHmmss");
            }
            else
            {
                tempName = Path.GetFileNameWithoutExtension(path) + "_iq_" + DateTime.Now.ToString("MMddHHmmss");
            }
            //确定目录是否存在
            if (!Directory.Exists(tempPath))
            {
                //创建它不存在的目录
                Directory.CreateDirectory(tempPath);
            }

            var pSaveFilePath = $"{tempPath}{tempName}{Path.GetExtension(path)}";
            if (!File.Exists(pSaveFilePath))//必须判断要复制的文件是否存在
            {
                File.Copy(path, pSaveFilePath, true);//三个参数分别是源文件路径，存储路径，若存储路径有相同文件是否替换
            }

            //更新IQ
            var msg = UpdateParameterNewIQ(pSaveFilePath);
            if (msg.state == MsgSt.Success)
            {
                if (File.Exists(pSaveFilePath))
                {
                    File.Delete(pSaveFilePath);
                }
                File.WriteAllLines(pSaveFilePath, msg.data, Encoding.Default);
                switch (btn.Tag.ToString())
                {
                    case "1":
                        SettingList_Help.SetTips128[8].data.Add(new TreeListValue() { ValueMember = pSaveFilePath, DisplayMember = Path.GetFileName(pSaveFilePath)  });
                        settingPathtvi_1.Properties.DataSource = SettingList_Help.SetTips128[8].data;
                        settingPathtvi_1.ItemIndex = SettingList_Help.SetTips128[8].data.Count() - 1;
                        break;
                    case "2":
                        SettingList_Help.SetTips128[9].data.Add(new TreeListValue() { ValueMember = pSaveFilePath, DisplayMember = Path.GetFileName(pSaveFilePath)  });
                        settingPathtvi_2.Properties.DataSource = SettingList_Help.SetTips128[9].data;
                        settingPathtvi_2.ItemIndex = SettingList_Help.SetTips128[9].data.Count() - 1;
                        break;
                    case "3":
                        SettingList_Help.SetTips128[10].data.Add(new TreeListValue() { ValueMember = pSaveFilePath, DisplayMember = Path.GetFileName(pSaveFilePath)  });
                        settingPathtvi_3.Properties.DataSource = SettingList_Help.SetTips128[10].data;
                        settingPathtvi_3.ItemIndex = SettingList_Help.SetTips128[10].data.Count() - 1;
                        break;
                    case "4":
                        SettingList_Help.SetTips128[11].data.Add(new TreeListValue() { ValueMember = pSaveFilePath, DisplayMember = Path.GetFileName(pSaveFilePath)  });
                        settingPathtvi_4.Properties.DataSource = SettingList_Help.SetTips128[11].data;
                        settingPathtvi_4.ItemIndex = SettingList_Help.SetTips128[11].data.Count() - 1;
                        break;
                    case "5":
                        SettingList_Help.SetTips128[12].data.Add(new TreeListValue() { ValueMember = pSaveFilePath, DisplayMember = Path.GetFileName(pSaveFilePath)  });
                        settingPathtvi_5.Properties.DataSource = SettingList_Help.SetTips128[12].data;
                        settingPathtvi_5.ItemIndex = SettingList_Help.SetTips128[12].data.Count() - 1;
                        break;
                    case "6":
                        SettingList_Help.SetTips128[13].data.Add(new TreeListValue() { ValueMember = pSaveFilePath, DisplayMember = Path.GetFileName(pSaveFilePath)  });
                        settingPathtvi_6.Properties.DataSource = SettingList_Help.SetTips128[13].data;
                        settingPathtvi_6.ItemIndex = SettingList_Help.SetTips128[13].data.Count() - 1;
                        break;
                    case "7":
                        SettingList_Help.SetTips128[14].data.Add(new TreeListValue() { ValueMember = pSaveFilePath, DisplayMember = Path.GetFileName(pSaveFilePath)  });
                        settingPathtvi_7.Properties.DataSource = SettingList_Help.SetTips128[14].data;
                        settingPathtvi_7.ItemIndex = SettingList_Help.SetTips128[14].data.Count() - 1;
                        break;
                    case "8":
                        SettingList_Help.SetTips128[15].data.Add(new TreeListValue() { ValueMember = pSaveFilePath, DisplayMember = Path.GetFileName(pSaveFilePath)  });
                        settingPathtvi_8.Properties.DataSource = SettingList_Help.SetTips128[15].data;
                        settingPathtvi_8.ItemIndex = SettingList_Help.SetTips128[15].data.Count() - 1;
                        break;
                    default:
                        break;
                }
            }
            else
            {
                XtraMessageBox.Show($"更新错误：{msg.msg}", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

        }
        #endregion
        #region chd

        private void oscvibtn1_Click(object sender, EventArgs e)
        {
            var btn = sender as SimpleButton;
            string path = string.Empty;
            switch (btn.Tag.ToString())
            {
                case "1":
                    path = settingPathcvi_1.EditValue.ToString();
                    break;
                case "2":
                    path = settingPathcvi_2.EditValue.ToString();
                    break;
                case "3":
                    path = settingPathcvi_3.EditValue.ToString();
                    break;
                case "4":
                    path = settingPathcvi_4.EditValue.ToString();
                    break;
                case "5":
                    path = settingPathcvi_5.EditValue.ToString();
                    break;
                case "6":
                    path = settingPathcvi_6.EditValue.ToString();
                    break;
                case "7":
                    path = settingPathcvi_7.EditValue.ToString();
                    break;
                case "8":
                    path = settingPathcvi_8.EditValue.ToString();
                    break;
                default:
                    path = string.Empty;
                    break;
            }

            if (string.IsNullOrEmpty(path) || path.Contains("请选择"))
            {
                DevExpress.XtraEditors.XtraMessageBox.Show($"1080配置 OS 文件路径未选择！", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            string tempPath = string.Empty;
            if (System.IO.Path.GetDirectoryName(path).Contains("SettingTemp"))
            {
                tempPath = System.IO.Path.GetDirectoryName(path) + "\\";
            }
            else
            {
                tempPath = System.IO.Path.GetDirectoryName(path) + "\\SettingTemp\\";
            }

            string tempName = string.Empty;
            if (Path.GetFileNameWithoutExtension(path).Contains("all"))
            {
                var t = Path.GetFileNameWithoutExtension(path);
                var end = t.IndexOf("_all");
                tempName = t.Substring(0, end) + "_all_" + DateTime.Now.ToString("MMddHHmmss");
            }
            else if (Path.GetFileNameWithoutExtension(path).Contains("iq"))
            {
                var t = Path.GetFileNameWithoutExtension(path);
                var end = t.IndexOf("_iq");
                tempName = t.Substring(0, end) + "_all_" + DateTime.Now.ToString("MMddHHmmss");
            }
            else
            {
                tempName = Path.GetFileNameWithoutExtension(path) + "_all_" + DateTime.Now.ToString("MMddHHmmss");
            }


            //确定目录是否存在
            if (!Directory.Exists(tempPath))
            {
                //创建它不存在的目录
                Directory.CreateDirectory(tempPath);
            }

            var pSaveFilePath = $"{tempPath}{tempName}{Path.GetExtension(path)}";
            if (!File.Exists(pSaveFilePath))//必须判断要复制的文件是否存在
            {
                File.Copy(path, pSaveFilePath, true);//三个参数分别是源文件路径，存储路径，若存储路径有相同文件是否替换
            }

            //更新OS
            var msg = UpdateParameter(pSaveFilePath);
            if (msg.state == MsgSt.Success)
            {
                if (File.Exists(pSaveFilePath))
                {
                    File.Delete(pSaveFilePath);
                }
                File.WriteAllLines(pSaveFilePath, msg.data, Encoding.Default);
                switch (btn.Tag.ToString())
                {
                    case "1":
                        SettingList_Help.SetTips128[16].data.Add(new TreeListValue() { ValueMember = pSaveFilePath, DisplayMember = Path.GetFileName(pSaveFilePath)  });
                        settingPathcvi_1.Properties.DataSource = SettingList_Help.SetTips128[16].data;
                        settingPathcvi_1.ItemIndex = SettingList_Help.SetTips128[16].data.Count() - 1;
                        break;
                    case "2":
                        SettingList_Help.SetTips128[17].data.Add(new TreeListValue() { ValueMember = pSaveFilePath, DisplayMember = Path.GetFileName(pSaveFilePath)  });
                        settingPathcvi_2.Properties.DataSource = SettingList_Help.SetTips128[17].data;
                        settingPathcvi_2.ItemIndex = SettingList_Help.SetTips128[17].data.Count() - 1;
                        break;
                    case "3":
                        SettingList_Help.SetTips128[18].data.Add(new TreeListValue() { ValueMember = pSaveFilePath, DisplayMember = Path.GetFileName(pSaveFilePath)  });
                        settingPathcvi_3.Properties.DataSource = SettingList_Help.SetTips128[18].data;
                        settingPathcvi_3.ItemIndex = SettingList_Help.SetTips128[18].data.Count() - 1;
                        break;
                    case "4":
                        SettingList_Help.SetTips128[19].data.Add(new TreeListValue() { ValueMember = pSaveFilePath, DisplayMember = Path.GetFileName(pSaveFilePath)  });
                        settingPathcvi_4.Properties.DataSource = SettingList_Help.SetTips128[19].data;
                        settingPathcvi_4.ItemIndex = SettingList_Help.SetTips128[19].data.Count() - 1;
                        break;
                    case "5":
                        SettingList_Help.SetTips128[20].data.Add(new TreeListValue() { ValueMember = pSaveFilePath, DisplayMember = Path.GetFileName(pSaveFilePath)  });
                        settingPathcvi_5.Properties.DataSource = SettingList_Help.SetTips128[20].data;
                        settingPathcvi_5.ItemIndex = SettingList_Help.SetTips128[20].data.Count() - 1;
                        break;
                    case "6":
                        SettingList_Help.SetTips128[21].data.Add(new TreeListValue() { ValueMember = pSaveFilePath, DisplayMember = Path.GetFileName(pSaveFilePath)  });
                        settingPathcvi_6.Properties.DataSource = SettingList_Help.SetTips128[21].data;
                        settingPathcvi_6.ItemIndex = SettingList_Help.SetTips128[21].data.Count() - 1;
                        break;
                    case "7":
                        SettingList_Help.SetTips128[22].data.Add(new TreeListValue() { ValueMember = pSaveFilePath, DisplayMember = Path.GetFileName(pSaveFilePath)  });
                        settingPathcvi_7.Properties.DataSource = SettingList_Help.SetTips128[22].data;
                        settingPathcvi_7.ItemIndex = SettingList_Help.SetTips128[22].data.Count() - 1;
                        break;
                    case "8":
                        SettingList_Help.SetTips128[23].data.Add(new TreeListValue() { ValueMember = pSaveFilePath, DisplayMember = Path.GetFileName(pSaveFilePath)  });
                        settingPathcvi_8.Properties.DataSource = SettingList_Help.SetTips128[23].data;
                        settingPathcvi_8.ItemIndex = SettingList_Help.SetTips128[23].data.Count() - 1;
                        break;
                    default:
                        break;
                }
            }
            else
            {
                XtraMessageBox.Show($"更新错误：{msg.msg}", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }

        private void iqcvibtn1_Click(object sender, EventArgs e)
        {
            var btn = sender as SimpleButton;
            string path = string.Empty;
            switch (btn.Tag.ToString())
            {
                case "1":
                    path = settingPathcvi_1.EditValue.ToString();
                    break;
                case "2":
                    path = settingPathcvi_2.EditValue.ToString();
                    break;
                case "3":
                    path = settingPathcvi_3.EditValue.ToString();
                    break;
                case "4":
                    path = settingPathcvi_4.EditValue.ToString();
                    break;
                case "5":
                    path = settingPathcvi_5.EditValue.ToString();
                    break;
                case "6":
                    path = settingPathcvi_6.EditValue.ToString();
                    break;
                case "7":
                    path = settingPathcvi_7.EditValue.ToString();
                    break;
                case "8":
                    path = settingPathcvi_8.EditValue.ToString();
                    break;
                default:
                    path = string.Empty;
                    break;
            }
            if (string.IsNullOrEmpty(path) || path.Contains("请选择"))
            {
                DevExpress.XtraEditors.XtraMessageBox.Show($"1080配置 IQ 文件路径未选择！", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            string tempPath = string.Empty;
            if (System.IO.Path.GetDirectoryName(path).Contains("SettingTemp"))
            {
                tempPath = System.IO.Path.GetDirectoryName(path) + "\\";
            }
            else
            {
                tempPath = System.IO.Path.GetDirectoryName(path) + "\\SettingTemp\\";
            }
            string tempName = string.Empty;
            if (Path.GetFileNameWithoutExtension(path).Contains("iq"))
            {
                var t = Path.GetFileNameWithoutExtension(path);
                var end = t.IndexOf("_iq");
                tempName = t.Substring(0, end) + "_iq_" + DateTime.Now.ToString("MMddHHmmss");
            }
            else if (Path.GetFileNameWithoutExtension(path).Contains("all"))
            {
                var t = Path.GetFileNameWithoutExtension(path);
                var end = t.IndexOf("_all");
                tempName = t.Substring(0, end) + "_iq_" + DateTime.Now.ToString("MMddHHmmss");
            }
            else
            {
                tempName = Path.GetFileNameWithoutExtension(path) + "_iq_" + DateTime.Now.ToString("MMddHHmmss");
            }
            //确定目录是否存在
            if (!Directory.Exists(tempPath))
            {
                //创建它不存在的目录
                Directory.CreateDirectory(tempPath);
            }

            var pSaveFilePath = $"{tempPath}{tempName}{Path.GetExtension(path)}";
            if (!File.Exists(pSaveFilePath))//必须判断要复制的文件是否存在
            {
                File.Copy(path, pSaveFilePath, true);//三个参数分别是源文件路径，存储路径，若存储路径有相同文件是否替换
            }

            //更新IQ
            var msg = UpdateParameterNewIQ(pSaveFilePath);
            if (msg.state == MsgSt.Success)
            {
                if (File.Exists(pSaveFilePath))
                {
                    File.Delete(pSaveFilePath);
                }
                File.WriteAllLines(pSaveFilePath, msg.data, Encoding.Default);
                switch (btn.Tag.ToString())
                {
                    case "1":
                        SettingList_Help.SetTips128[16].data.Add(new TreeListValue() { ValueMember = pSaveFilePath, DisplayMember = Path.GetFileName(pSaveFilePath)  });
                        settingPathcvi_1.Properties.DataSource = SettingList_Help.SetTips128[16].data;
                        settingPathcvi_1.ItemIndex = SettingList_Help.SetTips128[16].data.Count() - 1;
                        break;
                    case "2":
                        SettingList_Help.SetTips128[17].data.Add(new TreeListValue() { ValueMember = pSaveFilePath, DisplayMember = Path.GetFileName(pSaveFilePath)  });
                        settingPathcvi_2.Properties.DataSource = SettingList_Help.SetTips128[17].data;
                        settingPathcvi_2.ItemIndex = SettingList_Help.SetTips128[17].data.Count() - 1;
                        break;
                    case "3":
                        SettingList_Help.SetTips128[18].data.Add(new TreeListValue() { ValueMember = pSaveFilePath, DisplayMember = Path.GetFileName(pSaveFilePath)  });
                        settingPathcvi_3.Properties.DataSource = SettingList_Help.SetTips128[18].data;
                        settingPathcvi_3.ItemIndex = SettingList_Help.SetTips128[18].data.Count() - 1;
                        break;
                    case "4":
                        SettingList_Help.SetTips128[19].data.Add(new TreeListValue() { ValueMember = pSaveFilePath, DisplayMember = Path.GetFileName(pSaveFilePath)  });
                        settingPathcvi_4.Properties.DataSource = SettingList_Help.SetTips128[19].data;
                        settingPathcvi_4.ItemIndex = SettingList_Help.SetTips128[19].data.Count() - 1;
                        break;
                    case "5":
                        SettingList_Help.SetTips128[20].data.Add(new TreeListValue() { ValueMember = pSaveFilePath, DisplayMember = Path.GetFileName(pSaveFilePath)  });
                        settingPathcvi_5.Properties.DataSource = SettingList_Help.SetTips128[20].data;
                        settingPathcvi_5.ItemIndex = SettingList_Help.SetTips128[20].data.Count() - 1;
                        break;
                    case "6":
                        SettingList_Help.SetTips128[21].data.Add(new TreeListValue() { ValueMember = pSaveFilePath, DisplayMember = Path.GetFileName(pSaveFilePath)  });
                        settingPathcvi_6.Properties.DataSource = SettingList_Help.SetTips128[21].data;
                        settingPathcvi_6.ItemIndex = SettingList_Help.SetTips128[21].data.Count() - 1;
                        break;
                    case "7":
                        SettingList_Help.SetTips128[22].data.Add(new TreeListValue() { ValueMember = pSaveFilePath, DisplayMember = Path.GetFileName(pSaveFilePath)  });
                        settingPathcvi_7.Properties.DataSource = SettingList_Help.SetTips128[22].data;
                        settingPathcvi_7.ItemIndex = SettingList_Help.SetTips128[22].data.Count() - 1;
                        break;
                    case "8":
                        SettingList_Help.SetTips128[23].data.Add(new TreeListValue() { ValueMember = pSaveFilePath, DisplayMember = Path.GetFileName(pSaveFilePath)  });
                        settingPathcvi_8.Properties.DataSource = SettingList_Help.SetTips128[23].data;
                        settingPathcvi_8.ItemIndex = SettingList_Help.SetTips128[23].data.Count() - 1;
                        break;
                    default:
                        break;
                }
            }
            else
            {
                XtraMessageBox.Show($"更新错误：{msg.msg}", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        #endregion
        #region cvbs

        private void oscvbsbtn1_Click(object sender, EventArgs e)
        {
            var btn = sender as SimpleButton;
            string path = string.Empty;
            switch (btn.Tag.ToString())
            {
                case "1":
                    path = settingPathcvbs_1.EditValue.ToString();
                    break;
                case "2":
                    path = settingPathcvbs_2.EditValue.ToString();
                    break;
                case "3":
                    path = settingPathcvbs_3.EditValue.ToString();
                    break;
                case "4":
                    path = settingPathcvbs_4.EditValue.ToString();
                    break;
                case "5":
                    path = settingPathcvbs_5.EditValue.ToString();
                    break;
                case "6":
                    path = settingPathcvbs_6.EditValue.ToString();
                    break;
                case "7":
                    path = settingPathcvbs_7.EditValue.ToString();
                    break;
                case "8":
                    path = settingPathcvbs_8.EditValue.ToString();
                    break;
                default:
                    path = string.Empty;
                    break;
            }

            if (string.IsNullOrEmpty(path) || path.Contains("请选择"))
            {
                DevExpress.XtraEditors.XtraMessageBox.Show($"1080配置 OS 文件路径未选择！", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            string tempPath = string.Empty;
            if (System.IO.Path.GetDirectoryName(path).Contains("SettingTemp"))
            {
                tempPath = System.IO.Path.GetDirectoryName(path) + "\\";
            }
            else
            {
                tempPath = System.IO.Path.GetDirectoryName(path) + "\\SettingTemp\\";
            }

            string tempName = string.Empty;
            if (Path.GetFileNameWithoutExtension(path).Contains("all"))
            {
                var t = Path.GetFileNameWithoutExtension(path);
                var end = t.IndexOf("_all");
                tempName = t.Substring(0, end) + "_all_" + DateTime.Now.ToString("MMddHHmmss");
            }
            else if (Path.GetFileNameWithoutExtension(path).Contains("iq"))
            {
                var t = Path.GetFileNameWithoutExtension(path);
                var end = t.IndexOf("_iq");
                tempName = t.Substring(0, end) + "_all_" + DateTime.Now.ToString("MMddHHmmss");
            }
            else
            {
                tempName = Path.GetFileNameWithoutExtension(path) + "_all_" + DateTime.Now.ToString("MMddHHmmss");
            }


            //确定目录是否存在
            if (!Directory.Exists(tempPath))
            {
                //创建它不存在的目录
                Directory.CreateDirectory(tempPath);
            }

            var pSaveFilePath = $"{tempPath}{tempName}{Path.GetExtension(path)}";
            if (!File.Exists(pSaveFilePath))//必须判断要复制的文件是否存在
            {
                File.Copy(path, pSaveFilePath, true);//三个参数分别是源文件路径，存储路径，若存储路径有相同文件是否替换
            }

            //更新OS
            var msg = UpdateParameter(pSaveFilePath);
            if (msg.state == MsgSt.Success)
            {
                if (File.Exists(pSaveFilePath))
                {
                    File.Delete(pSaveFilePath);
                }
                File.WriteAllLines(pSaveFilePath, msg.data, Encoding.Default);
                switch (btn.Tag.ToString())
                {
                    case "1":
                        SettingList_Help.SetTips128[24].data.Add(new TreeListValue() { ValueMember = pSaveFilePath, DisplayMember = Path.GetFileName(pSaveFilePath)  });
                        settingPathcvbs_1.Properties.DataSource = SettingList_Help.SetTips128[24].data;
                        settingPathcvbs_1.ItemIndex = SettingList_Help.SetTips128[24].data.Count() - 1;
                        break;
                    case "2":
                        SettingList_Help.SetTips128[25].data.Add(new TreeListValue() { ValueMember = pSaveFilePath, DisplayMember = Path.GetFileName(pSaveFilePath)  });
                        settingPathcvbs_2.Properties.DataSource = SettingList_Help.SetTips128[25].data;
                        settingPathcvbs_2.ItemIndex = SettingList_Help.SetTips128[25].data.Count() - 1;
                        break;
                    case "3":
                        SettingList_Help.SetTips128[26].data.Add(new TreeListValue() { ValueMember = pSaveFilePath, DisplayMember = Path.GetFileName(pSaveFilePath)  });
                        settingPathcvbs_3.Properties.DataSource = SettingList_Help.SetTips128[26].data;
                        settingPathcvbs_3.ItemIndex = SettingList_Help.SetTips128[26].data.Count() - 1;
                        break;
                    case "4":
                        SettingList_Help.SetTips128[27].data.Add(new TreeListValue() { ValueMember = pSaveFilePath, DisplayMember = Path.GetFileName(pSaveFilePath)  });
                        settingPathcvbs_4.Properties.DataSource = SettingList_Help.SetTips128[27].data;
                        settingPathcvbs_4.ItemIndex = SettingList_Help.SetTips128[27].data.Count() - 1;
                        break;
                    case "5":
                        SettingList_Help.SetTips128[28].data.Add(new TreeListValue() { ValueMember = pSaveFilePath, DisplayMember = Path.GetFileName(pSaveFilePath)  });
                        settingPathcvbs_5.Properties.DataSource = SettingList_Help.SetTips128[28].data;
                        settingPathcvbs_5.ItemIndex = SettingList_Help.SetTips128[28].data.Count() - 1;
                        break;
                    case "6":
                        SettingList_Help.SetTips128[29].data.Add(new TreeListValue() { ValueMember = pSaveFilePath, DisplayMember = Path.GetFileName(pSaveFilePath)  });
                        settingPathcvbs_6.Properties.DataSource = SettingList_Help.SetTips128[29].data;
                        settingPathcvbs_6.ItemIndex = SettingList_Help.SetTips128[29].data.Count() - 1;
                        break;
                    case "7":
                        SettingList_Help.SetTips128[30].data.Add(new TreeListValue() { ValueMember = pSaveFilePath, DisplayMember = Path.GetFileName(pSaveFilePath)  });
                        settingPathcvbs_7.Properties.DataSource = SettingList_Help.SetTips128[30].data;
                        settingPathcvbs_7.ItemIndex = SettingList_Help.SetTips128[30].data.Count() - 1;
                        break;
                    case "8":
                        SettingList_Help.SetTips128[31].data.Add(new TreeListValue() { ValueMember = pSaveFilePath, DisplayMember = Path.GetFileName(pSaveFilePath)  });
                        settingPathcvbs_8.Properties.DataSource = SettingList_Help.SetTips128[31].data;
                        settingPathcvbs_8.ItemIndex = SettingList_Help.SetTips128[31].data.Count() - 1;
                        break;
                    default:
                        break;
                }
            }
            else
            {
                XtraMessageBox.Show($"更新错误：{msg.msg}", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }

        private void iqcvbsbtn1_Click(object sender, EventArgs e)
        {
            var btn = sender as SimpleButton;
            string path = string.Empty;
            switch (btn.Tag.ToString())
            {
                case "1":
                    path = settingPathcvbs_1.EditValue.ToString();
                    break;
                case "2":
                    path = settingPathcvbs_2.EditValue.ToString();
                    break;
                case "3":
                    path = settingPathcvbs_3.EditValue.ToString();
                    break;
                case "4":
                    path = settingPathcvbs_4.EditValue.ToString();
                    break;
                case "5":
                    path = settingPathcvbs_5.EditValue.ToString();
                    break;
                case "6":
                    path = settingPathcvbs_6.EditValue.ToString();
                    break;
                case "7":
                    path = settingPathcvbs_7.EditValue.ToString();
                    break;
                case "8":
                    path = settingPathcvbs_8.EditValue.ToString();
                    break;
                default:
                    path = string.Empty;
                    break;
            }
            if (string.IsNullOrEmpty(path) || path.Contains("请选择"))
            {
                DevExpress.XtraEditors.XtraMessageBox.Show($"1080配置 IQ 文件路径未选择！", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            string tempPath = string.Empty;
            if (System.IO.Path.GetDirectoryName(path).Contains("SettingTemp"))
            {
                tempPath = System.IO.Path.GetDirectoryName(path) + "\\";
            }
            else
            {
                tempPath = System.IO.Path.GetDirectoryName(path) + "\\SettingTemp\\";
            }
            string tempName = string.Empty;
            if (Path.GetFileNameWithoutExtension(path).Contains("iq"))
            {
                var t = Path.GetFileNameWithoutExtension(path);
                var end = t.IndexOf("_iq");
                tempName = t.Substring(0, end) + "_iq_" + DateTime.Now.ToString("MMddHHmmss");
            }
            else if (Path.GetFileNameWithoutExtension(path).Contains("all"))
            {
                var t = Path.GetFileNameWithoutExtension(path);
                var end = t.IndexOf("_all");
                tempName = t.Substring(0, end) + "_iq_" + DateTime.Now.ToString("MMddHHmmss");
            }
            else
            {
                tempName = Path.GetFileNameWithoutExtension(path) + "_iq_" + DateTime.Now.ToString("MMddHHmmss");
            }
            //确定目录是否存在
            if (!Directory.Exists(tempPath))
            {
                //创建它不存在的目录
                Directory.CreateDirectory(tempPath);
            }

            var pSaveFilePath = $"{tempPath}{tempName}{Path.GetExtension(path)}";
            if (!File.Exists(pSaveFilePath))//必须判断要复制的文件是否存在
            {
                File.Copy(path, pSaveFilePath, true);//三个参数分别是源文件路径，存储路径，若存储路径有相同文件是否替换
            }

            //更新IQ
            var msg = UpdateParameterNewIQ(pSaveFilePath);
            if (msg.state == MsgSt.Success)
            {
                if (File.Exists(pSaveFilePath))
                {
                    File.Delete(pSaveFilePath);
                }
                File.WriteAllLines(pSaveFilePath, msg.data, Encoding.Default);
                switch (btn.Tag.ToString())
                {
                    case "1":
                        SettingList_Help.SetTips128[24].data.Add(new TreeListValue() { ValueMember = pSaveFilePath, DisplayMember = Path.GetFileName(pSaveFilePath)  });
                        settingPathcvbs_1.Properties.DataSource = SettingList_Help.SetTips128[24].data;
                        settingPathcvbs_1.ItemIndex = SettingList_Help.SetTips128[24].data.Count() - 1;
                        break;
                    case "2":
                        SettingList_Help.SetTips128[25].data.Add(new TreeListValue() { ValueMember = pSaveFilePath, DisplayMember = Path.GetFileName(pSaveFilePath)  });
                        settingPathcvbs_2.Properties.DataSource = SettingList_Help.SetTips128[25].data;
                        settingPathcvbs_2.ItemIndex = SettingList_Help.SetTips128[25].data.Count() - 1;
                        break;
                    case "3":
                        SettingList_Help.SetTips128[26].data.Add(new TreeListValue() { ValueMember = pSaveFilePath, DisplayMember = Path.GetFileName(pSaveFilePath)  });
                        settingPathcvbs_3.Properties.DataSource = SettingList_Help.SetTips128[26].data;
                        settingPathcvbs_3.ItemIndex = SettingList_Help.SetTips128[26].data.Count() - 1;
                        break;
                    case "4":
                        SettingList_Help.SetTips128[27].data.Add(new TreeListValue() { ValueMember = pSaveFilePath, DisplayMember = Path.GetFileName(pSaveFilePath)  });
                        settingPathcvbs_4.Properties.DataSource = SettingList_Help.SetTips128[27].data;
                        settingPathcvbs_4.ItemIndex = SettingList_Help.SetTips128[27].data.Count() - 1;
                        break;
                    case "5":
                        SettingList_Help.SetTips128[28].data.Add(new TreeListValue() { ValueMember = pSaveFilePath, DisplayMember = Path.GetFileName(pSaveFilePath)  });
                        settingPathcvbs_5.Properties.DataSource = SettingList_Help.SetTips128[28].data;
                        settingPathcvbs_5.ItemIndex = SettingList_Help.SetTips128[28].data.Count() - 1;
                        break;
                    case "6":
                        SettingList_Help.SetTips128[29].data.Add(new TreeListValue() { ValueMember = pSaveFilePath, DisplayMember = Path.GetFileName(pSaveFilePath)  });
                        settingPathcvbs_6.Properties.DataSource = SettingList_Help.SetTips128[29].data;
                        settingPathcvbs_6.ItemIndex = SettingList_Help.SetTips128[29].data.Count() - 1;
                        break;
                    case "7":
                        SettingList_Help.SetTips128[30].data.Add(new TreeListValue() { ValueMember = pSaveFilePath, DisplayMember = Path.GetFileName(pSaveFilePath)  });
                        settingPathcvbs_7.Properties.DataSource = SettingList_Help.SetTips128[30].data;
                        settingPathcvbs_7.ItemIndex = SettingList_Help.SetTips128[30].data.Count() - 1;
                        break;
                    case "8":
                        SettingList_Help.SetTips128[31].data.Add(new TreeListValue() { ValueMember = pSaveFilePath, DisplayMember = Path.GetFileName(pSaveFilePath)  });
                        settingPathcvbs_8.Properties.DataSource = SettingList_Help.SetTips128[31].data;
                        settingPathcvbs_8.ItemIndex = SettingList_Help.SetTips128[31].data.Count() - 1;
                        break;
                    default:
                        break;
                }
            }
            else
            {
                XtraMessageBox.Show($"更新错误：{msg.msg}", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        #endregion


        public class TrLComparer : IEqualityComparer<TreeListValue>
        {
            public bool Equals(TreeListValue x, TreeListValue y)
            {
                return x.ValueMember == y.ValueMember;
            }

            public int GetHashCode(TreeListValue obj)
            {
                return obj.ToString().GetHashCode();
            }
        }

        private void commonTxt_EditValueChanged(object sender, EventArgs e)
        {
            if (isloadAgain) return;
            if (!string.IsNullOrEmpty(commonTxt.Text) && commonTxt.Text != "请选择文件")
            {
                //id 117  IsModified =1;
                var model99 = Bincurrency_BLL.GetSingle(c => c.GuidId == GuidNo && c.BinId == 117);
                if (null == model99)
                {
                    var mode102 = new bincurrency();
                    mode102.GuidId = GuidNo;
                    mode102.BinId = 117;
                    mode102.CreateTime = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss");
                    mode102.BinInPath = commonTxt.EditValue.ToString();
                    mode102.BinInName = Path.GetFileName(commonTxt.EditValue.ToString());
                    mode102.FileStatus = 2;
                    mode102.SerialNo = 0;
                    mode102.SortOrder = 0;
                    mode102.IsModified = 1;
                    Bincurrency_BLL.Insert(mode102);
                }
                else
                {
                    model99.CreateTime = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss");
                    model99.BinInPath = commonTxt.EditValue.ToString();
                    model99.BinInName = Path.GetFileName(commonTxt.EditValue.ToString());
                    Bincurrency_BLL.Update(model99);
                }

            }
        }

        private void simpleButton3_Click(object sender, EventArgs e)
        {
            DialogResult dr = DevExpress.XtraEditors.XtraMessageBox.Show($"选择YES保存后退出！ \r\n 选择NO直接退出！", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk);
            if (dr == DialogResult.No)
            {
                this.Close();
            }
            else
            {
                simpleButton1_Click_1(null, null);
            }
        }
        /// <summary>
        /// 更新编号
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void bianhaoLook_EditValueChanged(object sender, EventArgs e)
        {
            var model99 = Bincurrency_BLL.GetList(c => c.GuidId == GuidNo);
            if (!model99.Exists(c => c.BinId == 112 && c.SerialNo == 0 && c.GuidId == GuidNo)) //binid 写死112
            {
                var mode102 = new bincurrency();
                mode102.GuidId = GuidNo;
                mode102.BinId = 112;
                mode102.BinAddressNo = bianhaoLook.EditValue.ToString();
                mode102.BinAddressOutName = $"{bianhaoLook.EditValue.ToString()}.txt";
                mode102.SortOrder = 0;
                mode102.IsModified = (mode102.SortOrder == 0 ? 0 : 1);
                Bincurrency_BLL.Insert(mode102);
            }
            else
            {
                //更新
                var model = model99.First(c => c.BinId == 112 && c.SerialNo == 0 && c.GuidId == GuidNo);
                model.BinAddressNo = bianhaoLook.EditValue.ToString();
                model.BinAddressOutName = $"{bianhaoLook.EditValue.ToString()}.txt";
                Bincurrency_BLL.Update(model);
            }
        }

        public void fuzhi()
        {
            var aaa = listBin.Where(c => c.isDel == false && c.BinName != "").ToList();
            List<TreeListValue> listCName = new List<TreeListValue>();
            for (int i = 0; i < aaa.Count; i++)
            {
                listCName.Add(new TreeListValue { ValueMember = aaa[i].tag.ToString(), DisplayMember = aaa[i].BinName });
            }
            bianhaoLook.Properties.DataSource = listCName;
        }
    }
  
}